seeing different gem lists in cygwin and powershel

2019-07-06 14:59发布

问题:

I used the gem list command in powershell and cygwin and both show different gem lists. Cygwin shows

*** LOCAL GEMS ***

bundler (1.2.3)
json (1.7.5)
minitest (2.12.1)
rake (0.9.2.2)
rdoc (3.12)

while in powershell I see :

*** LOCAL GEMS ***

io-console (0.3)
json (1.5.4)
minitest (2.5.1)
rake (0.9.2.2)
rdoc (3.9.4)
sass (3.2.1)

So, the versions of same gem are also different in two.

Why is it so? Also, I was getting problems with bundle install while using rails(int both Cygwin and Powershell). Can it be because of this?

How do I ensure consistency in gems? Doesn't installing a gem via Powershell/cygwin make it available to the entire system?

So, I would like to install a fresh copy of gems and Rails which is consistent across Powershell and cygwin. How do I do that?

running gem environment in cygwin gives this:

RubyGems Environment:
  - RUBYGEMS VERSION: 1.8.23
  - RUBY VERSION: 1.9.3 (2012-11-10 patchlevel 327) [i386-cygwin]
  - INSTALLATION DIRECTORY: /usr/lib/ruby/gems/1.9.1
  - RUBY EXECUTABLE: /usr/bin/ruby.exe
  - EXECUTABLE DIRECTORY: /usr/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86-cygwin
  - GEM PATHS:
     - /usr/lib/ruby/gems/1.9.1
     - /cygdrive/c/SPB_Data/.gem/ruby/1.9.1
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://rubygems.org/

and in windows powershell it gives :

RubyGems Environment:
  - RUBYGEMS VERSION: 1.8.23
  - RUBY VERSION: 1.9.3 (2012-04-20 patchlevel 194) [i386-mingw32]
  - INSTALLATION DIRECTORY: C:/Ruby193/lib/ruby/gems/1.9.1
  - RUBY EXECUTABLE: C:/Ruby193/bin/ruby.exe
  - EXECUTABLE DIRECTORY: C:/Ruby193/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86-mingw32
  - GEM PATHS:
     - C:/Ruby193/lib/ruby/gems/1.9.1
     - C:/SPB_Data/.gem/ruby/1.9.1
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://rubygems.org/

回答1:

I can only guess based on what information you have given, but it sounds like you have a separate version of ruby installed in cygwin and windows.

One easy way to tell what's going on is to do a ruby -v and gem environment in both shells, which will tell you which ruby version you are using, and what version ruby thinks it's using, and where Rubygems is looking for gems.

To ensure consistency in gems on windows, I would suggest having one ruby installed and using Bundler to maintain your gems through Gemfile. Remove the ruby you installed through cygwin, and ensure the ruby you use is the same one in both environments (try ruby -v)

However, I'm not sure why you're getting bundler errors based on the information you've given.

EDIT AFTER UPDATE

So you definitely have two different versions of ruby installed, each with their own unique set of gems. You cannot use the windows version in cygwin, so what I would do would be uninstall the cygwin version (use the cygwin setup.exe to do this! If you don't have it, download it again from the cygwin website. You can indicate packages to remove as well as add) and make sure the /cygdrive/c/ruby193/bin is in your cygwin path, so that which ruby and which gem points at this directory.