I am having some path issues and trying to understand how to read and match the paths. Here is what I am doing:
$PATH
bash: /home/agenadinik/.rvm/gems/ruby-1.9.2-p180/bin:/home/agenadinik/.rvm/gems/ruby-1.9.2-p180#global/bin:/home/agenadinik/.rvm/rubies/ruby-1.9.2-p180/bin:/home/agenadinik/.rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games: No such file or directory
And then I am trying to see what is in my ruby environment:
$gem environment
/home/agenadinik/.rvm/rubies/ruby-1.9.2-p180/bin/gem:4:
RubyGems Environment:
- RUBYGEMS VERSION: 1.6.2
- RUBY VERSION: 1.9.2 (2011-02-18 patchlevel 180) [i686-linux]
- INSTALLATION DIRECTORY: /home/agenadinik/.rvm/gems/ruby-1.9.2-p180
- RUBY EXECUTABLE: /home/agenadinik/.rvm/rubies/ruby-1.9.2-p180/bin/ruby
- EXECUTABLE DIRECTORY: /home/agenadinik/.rvm/gems/ruby-1.9.2-p180/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-linux
- GEM PATHS:
- /home/agenadinik/.rvm/gems/ruby-1.9.2-p180
- /home/agenadinik/.rvm/gems/ruby-1.9.2-p180#global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
What I don't understand is which of my paths need to be matched up in my ruby environment and the $PATH
Also, is my $PATH pretty much what is set in my /home/username/.bashrc file?
What is usually the path of the Ruby executable that I need to point to?
Also, doing which ruby returns this:
$ which ruby
/home/agenadinik/.rvm/rubies/ruby-1.9.2-p180/bin/ruby
Thanks!!
You are using RVM. You have many available Ruby paths. When you source the RVM scripts in your bashrc it will modify your path. Every time you rvm use XXX it will modify your path to reflect the new version of Ruby and update all of the bins to match that version. If you are trying to make a proper shebang for a Ruby script you should use env.
#!/usr/bin/env ruby
This will find the current ruby executable in your path.
Related
This question already has an answer here:
Why is Ruby 1.9.2 on Windows 7 using a 1.9.1 path for gems? it is using c:/ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.0/lib/rails/commands.rb
(1 answer)
Closed 4 years ago.
I've been struggling with this for a while now. I want to use ruby-2.4.1 in my application and installed rbenv and also installed 2.4.1 with it.
I can confirm that ruby -v prints out 2.4.1 is being used.
gem env leads to the following:
RubyGems Environment:
- RUBYGEMS VERSION: 2.6.11
- RUBY VERSION: 2.4.1 (2017-03-22 patchlevel 111) [x86_64-darwin18]
- INSTALLATION DIRECTORY: /Users/thementoria/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0
- USER INSTALLATION DIRECTORY: /Users/thementoria/.gem/ruby/2.4.0
- RUBY EXECUTABLE: /Users/thementoria/.rbenv/versions/2.4.1/bin/ruby
- EXECUTABLE DIRECTORY: /Users/thementoria/.rbenv/versions/2.4.1/bin
- SPEC CACHE DIRECTORY: /Users/thementoria/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Users/thementoria/.rbenv/versions/2.4.1/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-18
- GEM PATHS:
- /Users/thementoria/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0
- /Users/thementoria/.gem/ruby/2.4.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /Users/thementoria/.rbenv/versions/2.4.1/bin
- /usr/local/Cellar/rbenv/1.1.1/libexec
- /Users/thementoria/.rbenv/bin
- /Users/thementoria/.rbenv/shims
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /usr/local/MacGPG2/bin
Note that my USER INSTALLATION DIRECTORY, INSTALLATION DIRECTORY and GEM PATHS have 2.4.0 in it.
What causes this to happen?
In my .bashrc I have:
eval "$(rbenv init -)"
export PATH="$HOME/.rbenv/bin:$PATH"
Any help would be appreciated.
All is fine. Ruby assumes that all gems within a minor version are fully compatible.
This is probably based on a 20 year old decision which would allow you to transfer installed gems within patch versions of Rubies, by simply copying or symlinking them, without downloading them again. I doubt that the same decision would be made today.
I'm trying to stand up a JRuby/Ruby-on-Rails environment on a Windows VM. As a result, I installed Ruby, Rails and the items from the RailsInstaller download. I then installed JRuby. Everything installed and I see both when I do jruby -v and ruby -v.
How do I get my Rails project to recognize JRuby instead of Ruby? Can I achieve this without installing RVM? Should I just install RVM on the Windows VM (which I was trying to avoid, but, maybe I shouldn't)? Do I just put a line in the Gemfile?
(My very limited experience with JRuby/Ruby-on-Rails is with using RVM on a Unix environment.)
Here's my output when I do a gem env:
RubyGems Environment:
- RUBYGEMS VERSION: 2.1.9
- RUBY VERSION: 1.9.3 (2014-09-25 patchlevel 392) [java]
- INSTALLATION DIRECTORY: C:/jruby-1.7.16/lib/ruby/gems/shared
- RUBY EXECUTABLE: C:/jruby-1.7.16/bin/jruby.exe
- EXECUTABLE DIRECTORY: C:/jruby-1.7.16/bin
- SPEC CACHE DIRECTORY: C:/Users/user/.gem/specs
- RUBYGEMS PLATFORMS:
- ruby
- universal-java-1.7
- GEM PATHS:
- C:/jruby-1.7.16/lib/ruby/gems/shared
- C:/Users/user/.gem/jruby/1.9
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- "install" => "--no-rdoc --no-ri --env-shebang"
- "update" => "--no-rdoc --no-ri --env-shebang"
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- C:\Windows\system32
- C:\Windows
- C:\Windows\System32\Wbem
- C:\Windows\System32\WindowsPowerShell\v1.0\
- c:\jruby-1.7.16\bin
- C:\RailsInstaller\Git\cmd
- C:\RailsInstaller\Ruby1.9.3\bin
- C:\Program Files\jruby-1.7.16\bin
Rails is a gem and it's installed within a Ruby installation by Rubygems, which is part of a Ruby distribution. Your path setting are set in the way, that the gem command is coming from Ruby and not from JRuby. You can remove all Ruby commands temporarily from your path, and as long as JRuby's commands are on the path it will automatically pick those.
By doing gem install bundler and bundle install you then will install Rails and all the project dependencies with JRuby.
However, that's what version managers actually do. They just switch the path settings properly. Using them simplifies the configuration of an development environment a lot. And, for Windows there is pik (RVM works only on Unix systems).
I started trying to set up a local rails installation for development. After I installed in using apt-get, however, I learned about RVM, so I removed the earlier one, and reinstalled from RVM. It looks like I have residual problems, though. Specifically, when I try to install rails I get...
$ gem install rails
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions into the /var/lib/gems/1.9.1 directory.
This already looks like a problem, because I don't want it to be in the /var/ directory, I want it to be in the user directory. So, I check the following...
$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.11
- RUBY VERSION: 1.9.3 (2011-10-30 patchlevel 0) [x86_64-linux]
- INSTALLATION DIRECTORY: /var/lib/gems/1.9.1
- RUBY EXECUTABLE: /usr/bin/ruby1.9.1
- EXECUTABLE DIRECTORY: /usr/local/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /var/lib/gems/1.9.1
- /home/myusername/.gem/ruby/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
As well as sudo'd:
$ sudo gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.11
- RUBY VERSION: 1.9.3 (2011-10-30 patchlevel 0) [x86_64-linux]
- INSTALLATION DIRECTORY: /var/lib/gems/1.9.1
- RUBY EXECUTABLE: /usr/bin/ruby1.9.1
- EXECUTABLE DIRECTORY: /usr/local/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /var/lib/gems/1.9.1
- /home/myusername/.gem/ruby/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
gems seem to live in /var/lib for some reason. Is this normal? How can I fix this so I can install the rails gem?
EDIT: UPDATE!
It appears to me that I have gems installed twice, once in /var/lib/gems/1.9.91 (bad) and once in /home/myusername/.gem/ruby/1.9.1 (good).
I think what is happening here is that when I type "gem" the installation in /var/lib/gems/1.9.1 (bad) is taking priority over /home/myusername/.gem/ruby/1.9.1 (good). Can anyone confirm that? Also, would it be OK and fix things just to delete the bad directory, or would that cause problems?
You missed to use ruby, you can do it with:
rvm use 1.9.3 --install
In case 1.9.3 was not installed, this command will also install it!
It also looks you are using Ubuntu, make sure you are not using RVM from Ubuntu package - that thing is broken! You can find instruction how to fix it here: https://stackoverflow.com/a/9056395/497756
Having some issues installing a gemset in ruby 1.8.7p334 (enterprise edition) running rails 1.2.6 on Fedora 8.
The main issue I have is that bundler installs the executables in /usr/lib/ruby/gems/1.8/bin. However, Gem installs the executables in /usr/bin, which is where I want them.
How can I tell bundler to place them in /usr/bin? I've looked at the --binstubs flag, but it doesn't seem to complete the necessary requirements.
Any help is much appreciated.
RubyGems Environment:
- RUBYGEMS VERSION: 1.5.2
- RUBY VERSION: 1.8.7 (2011-02-18 patchlevel 334) [x86_64-linux]
- INSTALLATION DIRECTORY: /usr/lib/ruby/gems/1.8
- RUBY EXECUTABLE: /usr/bin/ruby
- EXECUTABLE DIRECTORY: /usr/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /usr/lib/ruby/gems/1.8
- /root/.gem/ruby/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
Of course I find the answer after posting the question. It's the little-documented BUNDLE_BIN configuration key. It can be set by .bundle/config, an environment variable (my choice) or by bundle config. Looks like you can also specify it on the command line as --bin.
$ export BUNDLE_BIN="/usr/bin"
bin (BUNDLE_BIN)
Install executables from gems in the bundle to the specified directory.
Defaults to false.
Basically what I need is to install rubygems 1.3.5 on a machine (Debian) with 1.2.0 installed and having no root access.
What I've done so far: installed rubygems into $HOME/rubygems and set up GEM_HOME + added bin to the path. So running "which gem" shows me the new binary, not the old one. Also when I gem install something, it installs correctly into the new repository.
However, gem -v gives 1.2.0. And gem env gives the following:
RubyGems Environment:
- RUBYGEMS VERSION: 1.2.0
- RUBY VERSION: 1.8.7 (2008-08-11 patchlevel 72) [i486-linux]
- INSTALLATION DIRECTORY: /home/neutrino/rubygems/gems
- RUBY EXECUTABLE: /usr/bin/ruby1.8
- EXECUTABLE DIRECTORY: /home/neutrino/rubygems/gems/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-linux
- GEM PATHS:
- /home/neutrino/rubygems/gems
- /var/lib/gems/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- "gemhome" => "/home/neutrino/rubygems/gems"
- REMOTE SOURCES:
- http://gems.rubyforge.org/
Any hints will be appreciated. I just can't see what I'm doing wrong.
I expect that the problem will be related to the gem command finding the 1.2.0 version of RubyGems from the system lib paths ahead of your local version.
You could try setting the RUBYLIB environment variable to the directory containing the rubygems.rb file. The contents of RUBYLIB (colon delimited directories) gets prepended to the Ruby load path at startup.
It sounds like you need to take a look at rvm, especially its ability to have multiple gem sets.
http://rvm.io/
http://rvm.io/gemsets/
You need to put $HOME/rubygems/bin in your PATH environment before /usr/bin/.
If that's not doable I would rename $HOME/rubygems/bin/gem to $HOME/rubygems/bin/my_gem and do my_gem -v and continue using it that way(my_gem)