I am getting this error:
Warning! PATH is not properly set up, '/home/oscar/.rvm/gems/ruby-2.1.2/bin' is not at first place,
usually this is caused by shell initialization files - check them for 'PATH=...' entries,
it might also help to re-add RVM to your dotfiles: 'rvm get stable --auto-dotfiles',
to fix temporarily in this shell session run: 'rvm use ruby-2.1.2'.
rvm 1.25.28 (stable) by Wayne E. Seguin <wayneeseguin#gmail.com>, Michal Papis <mpapis#gmail.com> [https://rvm.io/]
when I go inside any virtualenv. It takes the virtualenv's path at first place. In this example I called my virtualenv borrar, so this is my PATH:
/home/oscar/projects/borrar/bin:/home/oscar/.rvm/gems/ruby-2.1.2/bin:/home/oscar/.rvm/gems/ruby-2.1.2#global/bin:/home/oscar/.rvm/rubies/ruby-2.1.2/bin:/home/oscar/eagle-6.6.0/bin:/home/oscar/android-studio/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin:/home/oscar/.rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/jvm/java-7-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin
My path outside any virtualenv is which I assume is correct because rvm is at first place.:
/home/oscar/.rvm/gems/ruby-2.1.2/bin:/home/oscar/.rvm/gems/ruby-2.1.2#global/bin:/home/oscar/.rvm/rubies/ruby-2.1.2/bin:/home/oscar/eagle-6.6.0/bin:/home/oscar/android-studio/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/jvm/java-7-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin:/home/oscar/.rvm/bin
Here is my .zshrc
and here my .zsh_profile where I load RVM at the end.
I appreciate all your help.
RVM Path Mismatch
RVM is complaining because it wants to be first in your PATH. It isn't; you've prepended something else, or your virtualenv wrappers have. This being the case, you can either reinvoke the RVM setup script from inside your virtualenv with . ~/.rvm/scripts/rvm, or you can deliberately silence the error as described below.
The RVM documentation strongly recommends that the RVM setup script be the last thing you invoke in your shell resource files so that (among other things) RVM can be sure it takes precedence over other Rubies or wrappers that might be in your PATH. However, if you're sure that you know what you're doing and that you won't encounter any PATH-related surprises, you can turn off this warning by adding this little-known configuration option to your .rvmrc file:
echo 'rvm_silence_path_mismatch_check_flag=1' >> ~/.rvmrc
Related
I'm coming from Windows to Linux (Ubuntu) so I'm new to the CLI. I had issues trying to install Rails so I figured a fresh install would help. I'm following "Installing Ruby the Correct Way."
I thought I had uninstalled Ruby, but after installing 2.1.4 it still shows some Ruby folders. Have I completely uninstalled Ruby?
Downloading ruby-2.1.4.tar.gz...
-> http://dqw8nmjcqpjn7.cloudfront.net/bf9952cdeb3a0c6a5a27745c9b4c0e5e264e92b669b2b08efb363f5156549204
Installing ruby-2.1.4...
Installed ruby-2.1.4 to /home/richard/.rbenv/versions/2.1.4
richard#richard-ThinkPad-T400:~$ rbenv global 2.1.4
richard#richard-ThinkPad-T400:~$ ruby -v
The program 'ruby' can be found in the following packages:
* ruby
* ruby1.8
Try: sudo apt-get install <selected package>
richard#richard-ThinkPad-T400:~$ sudo rbenv global 2.1.4
richard#richard-ThinkPad-T400:~$ ruby -v
The program 'ruby' can be found in the following packages:
* ruby
* ruby1.8
Try: sudo apt-get install <selected package>
Are the "the following packages" on my local system? or are they online?
EDIT
I've been getting this error when I try to install RVM (and some other applications):
GPG signature verification failed for '/home/richard/.rvm/archives/rvm-1.26.0.tgz' - 'https://github.com/wayneeseguin/rvm/releases/download/1.26.0/1.26.0.tar.gz.asc'!
try downloading the signatures:
gpg --keyserver hkp://keys.gnupg.net --recv-keys D39DC0E3
they can be compared with:
https://rvm.io/mpapis.asc
https://keybase.io/mpapis
Does this have anything to do with it? I wouldn't really think so but I'm a noob.
Don't sudo rbenv anything or you will summon Cthulhu. Use rbenv by itself.
Also, don't randomly follow guides on the internet until you're more familiar with your OS; They go stale, or start out wrong, or don't accurately apply to what you're doing. Instead, go to the source and follow the directions there.
To find out what is installed on your machine, use locate to quickly find Ruby instances. Something like:
locate /bin/ruby | grep -v .rbenv
should narrow down whether multiple Rubies are installed outside the ~/.rbenv directory.
Traditionally, you'll find a normally installed system-wide Ruby in /usr/bin/ruby. A user installed one from source will probably be in /usr/local/bin/ruby unless you specifically said otherwise, probably with a PREFIX= directive.
rbenv will default to installing Ruby in the ~/.rbenv hierarchy since it acts like a sandbox manager and will put all Rubies it installs underneath that directory. RVM, a similar application, will use ~/.rvm, and in both cases, the purpose is to keep them where the user's permissions are sufficient to install and update gems without requiring the use of sudo. For general use, avoid sudo unless you understand what you're about to do, as it can turn a computer into an under-desk heater in seconds.
The shell uses the PATH variable to figure out where to look for executable commands. It sounds like your PATH isn't set correctly. If you followed the directions on the rbenv site, they say how to enable rbenv by modifying your ~/.bash_profile script. Doing that, then closing and reopening your shell should bring rbenv to life.
Following that blog post, you are installing Ruby using a tool called rbenv, and if you only uninstalled one Ruby, that doesn't mean that all Rubies are uninstalled.
The message that you posted shows that it is a local install: Installed ruby-2.1.4 to /home/richard/.rbenv/versions/2.1.4 which is a copy of the 4th line of your message.
You can find out from whence your Ruby executable is being invoked by issuing at the command line:
which ruby
You will then know if the program is available and which it is. Using ruby -v if it is there will tell you the version.
You have done some of these steps and are finding out that your system does not know how to get to the Ruby, if it is indeed installed.
Right now, it is effectively uninstalled, as it is unavailable to your environment.
I am trying to upgrade to ruby 2.0.0 and I am running into problems getting rvm updated:
Here is my first error trying to update to ruby-2.0.0[-p353]:
Error running 'requirements_smf_update_system ruby-2.0.0[-p353]',
please read /usr/local/rvm/log/1385828966_ruby-2.0.0[-p353]/update_system.log
Requirements installation failed with status: 1.
So I tried:
rvm get stable --auto-dotfiles
And got the following warnings:
Can not update 'scripts/extras/completion.zsh/_rvm', it's a conflict between Zsh
and multiuser installation, prefix the command with 'rvmsudo' to update this file.
but it alerted that install was complete. When I run:
rvm usge:
I get this warning:
Warning! PATH is not properly set up, '/usr/local/rvm/gems/ruby-1.9.3-p194/bin' is not
at first place, usually this is caused by shell initialization files - check them for
'PATH=...' entries, it might also help to re-add RVM to your dotfiles:
'rvm get stable --auto-dotfiles', to fix temporarily in this shell session run:
'rvm use ruby-1.9.3-p194'
And I'm going in a circle. I would like to read:
/usr/local/rvm/log/1385828966_ruby-2.0.0[-p353]/update_system.log
but I don't know where to find it. I must have accidentally set up rvm with multiuser instead of single user but I can't be sure because I used to tutorial to set is up.
Does anyone have any ideas?
Thanks in advance.
In ruby-2.0.0[-p353] the brackets [] mean optional so you can either write:
rvm install ruby-2.0.0
OR:
rvm install ruby-2.0.0-p353
I am trying to install rvm on a vagrant box Ubuntu 12.04. When I run the vagrant script the installation halts due to an error with this command:
curl -L https://get.rvm.io | sudo bash -s stable --ruby=$RUBY_VER --auto-dotfiles --verify-downloads 1
This is the output of that command running inside the vagrant script:
Turning on auto dotfiles mode.
Please read and follow further instructions.
Press ENTER to continue.
Downloading RVM from wayneeseguin branch stable
Upgrading the RVM installation in /usr/local/rvm/
source /etc/profile.d/rvm.sh
Upgrade of RVM in /usr/local/rvm/ is complete.
Upgrade Notes:
* No new notes to display.
# In case of problems:
# run and read: rvm notes
# read docs: http://rvm.io/
# talk to us: http://webchat.freenode.net/?channels=rvm
# read cheatsheet: http://cheat.errtheblog.com/s/rvm
# watch screencast: http://screencasts.org/episodes/how-to-use-rvm
# open a bug report: https://github.com/wayneeseguin/rvm/issues
# vagrant,
#
# Thank you for using RVM!
# I sincerely hope that RVM helps to make your life easier and more enjoyable!
!!
#
# ~Wayne
rvm 1.21.6 (stable) by Wayne E. Seguin <wayneeseguin#gmail.com>, Michal Papis <m
papis#gmail.com> [https://rvm.io/]
Searching for binary rubies, this might take some time.
.o binary rubies available for: ubuntu/12.04/i386/ruby-1.9.3-p374
Continuing with compilation. Please read 'rvm help mount' to get more informatio
n on binary rubies.
Installing requirements for ubuntu, might require sudo password.
Requirements installation successful.
, this may take a while depending on your cpu(s)...es/ruby-1.9.3-p374
, this may take a while depending on your connection...
.tar.bz2', it's not possible to validate it.ng.org/pub/ruby/1.9/ruby-1.9.3-p374
This could be because your RVM install's list of versions is out of date. You ma
y want to
update your list of rubies by running 'rvm get stable' and try again.
If that does not resolve the issue and you wish to continue with unverified down
load
add '--verify-downloads 1' after the command.
There has been an error fetching the ruby interpreter. Halting the installation.
However when I try to run the same instruction on the command line of the vagrant box it seems to work:
vagrant#precise32:~$ curl -sSL https://get.rvm.io | sudo bash -s stable --ruby=1.9.3-p374 --auto-dotfiles --verify-downloads 1
The output is this:
Turning on auto dotfiles mode.
Please read and follow further instructions.
Press ENTER to continue.
Downloading RVM from wayneeseguin branch stable
Upgrading the RVM installation in /usr/local/rvm/
Upgrade of RVM in /usr/local/rvm/ is complete.
Upgrade Notes:
* No new notes to display.
# In case of problems:
# run and read: rvm notes
# read docs: http://rvm.io/
# talk to us: http://webchat.freenode.net/?channels=rvm
# read cheatsheet: http://cheat.errtheblog.com/s/rvm
# watch screencast: http://screencasts.org/episodes/how-to-use-rvm
# open a bug report: https://github.com/wayneeseguin/rvm/issues
# vagrant,
#
# Thank you for using RVM!
# I sincerely hope that RVM helps to make your life easier and more enjoyable!!!
#
# ~Wayne
rvm 1.21.6 (stable) by Wayne E. Seguin <wayneeseguin#gmail.com>, Michal Papis <mpapis#gmail.com> [https://rvm.io/]
Already installed ruby-1.9.3-p374.
To reinstall use:
rvm reinstall 1.9.3-p374
Creating alias default for ruby-1.9.3-p374.
Recording alias default for ruby-1.9.3-p374.
Creating default links/files
Saving wrappers to '/usr/local/rvm/bin'........
* To start using RVM you need to run `source /usr/local/rvm/scripts/rvm`
in all your open shell windows, in rare cases you need to reopen all shell windows.
Any ideas? I guess I could run manually the instructions on the vagrant files one by one but it would ruin the entire purpose of using provisioning. Thanks in advance.
Nevermind. It happened that my Git was configured to convert line ending from Linux to Windows format automatically, so when I downloaded the vagrant files they turned useless when Linux tried to extract Ruby version (and other stuff like that) from them.
So the solution in my case was to reinstall Git, setting "Configuring the line ending conversions" to "Checkout as-is, commit as-is":
I want to use rbenv for setting ruby versions on a project per project basis. Otherwise, I want to use my default system ruby setup for everything else.
The problem I am having is the even though rbenv version returns system, gem command still uses the rbenv shim (.rbenv/shims/gem). So when I do gem environment my INSTALLATION DIRECTORY is '/Library/Ruby/Gems/1.8'. I would rather it remains ~/.gem/. I can see it still is that when I run /usr/bin/gem enviroment. I can't figure out where the rbenv shim gem is getting its settings from.
I've tried modifying my GEM_HOME both in my shell, and changing it in ~/.gemrc but that has no effect. I've been searching around with no luck. Hopefully someone here can help. Just some pointers to where the rbenv gem shim is pulling its values from would be helpful.
thanks
Since rbenv shims are pretty high in your PATH, their purpose is to intercept any invocation of ruby, gem, and similar, even if the currently selected Ruby version is "system". You shouldn't be worried about that.
Now, the default installation path for your system Ruby will always be /Library/Ruby/Gems/1.8. Here's my RBENV_VERSION=system gem env:
- GEM PATHS:
- /Library/Ruby/Gems/1.8
- /Users/mislav/.gem/ruby/1.8
- /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8
However, if you don't use sudo (and you shouldn't), gem install won't have write access to that directory, and will install the gems in the next writeable path, which is ~/.gem/ruby/1.8. That seems to be the behavior you want.
The gems I install via sudo gem install ... can't be executed (I get a command not found).
They seem to install into /usr/local/Cellar/ which is Brew's install directory (also, the gems in /Library/Ruby/ don't work either). Is there anything else I need to do to make the gems executable? I'm using ZSH on Mac OS X 10.6 with Ruby v1.8 for the one in Brew.
EDIT: It seems to be working now. I just went out for a few hours and came back to try it again.
Homebrew is nice. However unlike brew and npm, gem does not make aliases in /usr/local/bin automatically.
Solution
I went for a very simple approach (as of March 2020):
# Based on "`brew --prefix ruby`/bin"
export PATH=/usr/local/opt/ruby/bin:$PATH
# Based on "`gem environment gemdir`/bin"
export PATH=/usr/local/lib/ruby/gems/3.0.0/bin:$PATH
Add this to your .bashrc (or .bash_profile, .zshrc, etc.).
That's it! Now all Ruby bins and installed gems will be available from your shell!
In older versions of Homebrew (before 2017), there was a separate package for Ruby 2 called ruby20, for which you'd use the following snippet instead:
export PATH=/usr/local/opt/ruby20/bin:$PATH
This line was the only line needed at the time. But, in Ruby 2.1 the gems got moved to a separate directory. No longer under /usr/local/opt/ruby/bin, but instead at /usr/local/lib/ruby/gems/2.0.0/bin (where "2.0.0" is the last major Ruby version for Gem's purposes).
How it works
Homebrew keeps track of where it installed a package, and maintains a symbolic link for you that points there.
$ brew --prefix ruby
/usr/local/opt/ruby
$ l /usr/local/opt/ruby
/usr/local/opt/ruby# -> ../Cellar/ruby/2.5.3_1
Effectively, adding /usr/local/opt/ruby to PATH is the same as the following:
export PATH=/usr/local/Cellar/ruby/2.5.3_1/bin:$PATH
Except, this long version hardcodes the currently installed version of Ruby and would stop working next time you upgrade Ruby.
As for Gem, the following command will tell you the exact directory Gem adds new packages to:
$ gem environment gemdir
/usr/local/lib/ruby/gems/2.7.0
Tools
These tools were meant to automatically bridge between Homebrew and Gem:
josh/brew-gem (no longer exists)
indirect/brewbygems (unmaintained)
I haven't used these but they might work for you.
brew unlink ruby; brew link ruby might add symlinks to /usr/local/bin/:
$ which sass
$ brew unlink ruby; brew link ruby
Unlinking /usr/local/Cellar/ruby/2.0.0-p0... 20 links removed
Linking /usr/local/Cellar/ruby/2.0.0-p0... 31 symlinks created
$ which sass
/usr/local/bin/sass
brew --prefix ruby is still pretty slow, but you could also just add /usr/local/opt/ruby/bin to the path.
$ time brew --prefix ruby
/usr/local/opt/ruby
0.216
$ time brew --prefix ruby
/usr/local/opt/ruby
0.076
$ stat -f%Y /usr/local/opt/ruby
../Cellar/ruby/2.0.0-p0
I like home brew. There's probably a better way to do this, but if you run:
gem environment
That will print out a nice list of all the relevant paths. Look for the one labeled EXECUTABLE DIRECTORY. That's the one you want to add to your path. In my case that's /usr/local/Cellar/ruby/1.9.3-p362/bin/ruby but I would imagine it would change with newer version of Ruby.
I'm using /bin/bash as my shell, but the process of adding it to your path should be pretty much the name.
I use TextWrangler (via the command line tools) to edit my .profile file. To do that, it's just:
edit ~/.profile
When your done, either close your terminal and open a new one, or run:
source ~/.profile
Using the info in Timo's answer, I've got this:
PATH=/usr/local/opt/ruby/bin:$PATH
GEMSDIR=$(gem environment gemdir)/bin
PATH=$GEMSDIR:$PATH
export PATH
Works for Homebrew, works for the separate gems directory, and doesn't hardcode a Ruby version.
You can be fine with ruby installed by homebrew too.. You just lack the functionality of custom gemsets with homebrew.
first do:
sudo nano /etc/paths
this will bring up nano editor,
then add the following to the paths:
/usr/local/Cellar/ruby/1.9.3-p194/bin
your version of ruby will probably vary.
Thats it. It should now detect your gems.
Oh, btw, you need to Ctrl+X > y > ENTER to save a file in nano.
Instead of using => $(cd $(which gem)/..; pwd)
You could use this instead => $(brew --prefix ruby)/bin
I think this evolve a bit.
Just add
export PATH=/usr/local/opt/ruby/bin:$PATH
To your .bashrc (or .bash_profile, .zshrc/.bashrc, .. – whatever you use).
If you have a problem with ruby itself
brew unlink ruby
brew link ruby