I am doing the Ruby on Rails 4 essential training with Kevin Skoglund. I installed Xcode and Homebrew no problems, was following along just fine when I went to do the command rbenv global 2.3.0 to change to the newest version, it won't do it. I was instructed to logout and back in, i shut down and restarted and I am still in version 2.0. How do I get it to change? I am a super noob, but I am brave. I would love to figure this out so i can get started.Also, i went to update my gems and this happened,
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
So I was stopped dead in my tracks, any help will be much appreciated
It's probably the case you missed a step on the rbenv installation. Unless the stub is installed in your .bash_profile (or equivalent), then rbenv won't engage on your shells properly.
Try repeating step two on the Basic GitHub Checkout step:
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
Then check that it's installed correctly:
type rbenv
Which should be a function.
What you're describing is probably a $PATH issue where the system Ruby is taking priority. The rbenv one needs to come first.
Related
I just switched from bash to zsh, installing its latest version with oh-my-zsh.
Disclosure: I'm a newbie so maybe some stuff are pretty obvious for more experimented developers.
According to what I've read so far, I know I should redirect $PATHbut don't know exactly what to do, as I don't really see any clear timeline and explanation about what to do (I've been through the zsh documentation, but things didn't really become clearer). I'm running a Mac on El Capitan 10.11.6. and I'm specifically having troubles installing the right ruby and rails versions.
As an example, I've installed ruby 2.3, I've executed ~rbenv global 2.3.1 but still ruby -v gives me back 2.0.0.
Can anyone please help me to do all the set up ?
Thanks :)
Run rbenv init - it will give you instructions for hooking rbenv into your shell.
MaxBook% rbenv init
# Load rbenv automatically by appending
# the following to ~/.zshrc:
eval "$(rbenv init -)"
When I execute the command:
rails s in my project, the console display the message:
Your Ruby version is 2.0.0, but your Gemfile specified 2.1.2
I executed the command:
brew upgrade rbenv ruby-build
rbenv install --list
and the version 2.1.2 appears in the list.
Then, I executed the command: rbenv rehash, but appears the same message when I executed the command:
rails s.
In my Gemfile file, is listed the:
ruby '2.1.2'
but I'm not looking replace this value with the previous version.
And if I execute :
rvm use 2.1.2
Is displayed:
Warning! PATH is not properly set up,
'/Users/Jarvis/.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'. Using /Users/Jarvis/.rvm/gems/ruby-2.1.2 Warning!
Executable 'ruby' missing, something went wrong with this ruby
installation! Warning! Executable 'gem' missing, something went wrong
with this ruby installation! Warning! Executable 'irb' missing,
something went wrong with this ruby installation!
What I'm doing wrong?
RVM and RBenv are actually similar tools. There are no practical reasons to keep them alongside each other in one session (and on one machine most of the time). They both rely on modifying PATH environment variable to get the Ruby and supplementary binaries closer for easy use.
And that's what RVM complains about: PATH is not what it expects to be. That said, RBEnv apparently tampered with it. Since these tools do their best to overtake ruby, gem, irb and stuff, they may very well conflict with each other on occasions.
So, remove one of them. Which one, is up to you. Removing RVM is as easy as:
rvm implode
...that will remove RVM's files, rubies and gems for them, but you might also want to inspect .bash_profile, .profile and .bashrc for relevant lines.
The uninstallation process for RBEnv seems to be the manual one: remove the folder, review the files listed above for relevant lines.
I'm trying to do the One Month Rails program. After doing some research on some warnings, I damaged my Ruby and Rails installation. I uninstalled RVM, Ruby and Rails and messed up everything.
Opening a new terminal directly gives me:
Last login: Wed Aug 21 23:04:17 on ttys001
-bash: /Users/marcboehle/.rvm/scripts/rvm: No such file or directory
I tried to uninstall RVM, and everything else and wanted to start from scratch but with every new installation of RVM, Ruby and Rails it leads to the same errors.
The next thing is:
Upgrading the RVM installation in /usr/local/rvm/
Can not automatically remove lines with 'rvm_autolibs_flag=' from '/etc/rvmrc', please clean it manually.
Found 4800 directories with mode different then '775', use `--debug` to see the list, prefix the command with 'rvmsudo' to fix it, if the situation persist report a bug.
Found 18220 files with mode different then '664' or '775', use `--debug` to see the list, prefix the command with 'rvmsudo' to fix it, if the situation persist report a bug.
Upgrade of RVM in /usr/local/rvm/ is complete.
lab037:~ username$ rvm install
Warning! PATH is not properly set up, '/usr/local/rvm/gems/ruby-1.9.2-p320/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.2-p320'.
Can not use or install 'all' rubies.
Is there a good way to get rid of everything that's connected to Ruby, Rails and RVM and start from the beginning with a fresh installation? I can't figure out where /etc/rvmrc is.
The shell problems that you're having come from /Users/marcboehle/.profile or /Users/marcboehle/.bash_profile. Those will contain the directives for RVM. For example here's mine:
brambook-pro-2:~ bram$ more ~/.bash_profile
export PATH=/Users/bram/.rvm/bin:/usr/local/mysql/bin:$PATH
$HOME/.rvm/scripts/rvm
You'll want to remove the PATH items that contain RVM, then follow the installation instructions and see what you get.
I have both ruby and rails installed in:
/usr/local/bin/ruby
/usr/bin/ruby
/usr/local/bin/ruby
This is causing problems when I try to run certains commands like ruby script/console
How do I remove some of these installations of both ruby and rails?
RVM will help you for sure. Check out RVM here
Preventing this kind of situations is the very role of RVM and it's gemsets.
I encourage you to check it out.
There are a few options. First one would be to get your ruby system install in good order. There is no harm in renaming removing those multiple ruby file in your diverse bin folders. Get the stable release of 1.9.2 and gem install whatever you need then. Googling around to fill the gaps you may have here
Quick and dirty you can do:
Get the latest stable release of ruby 1.9.2, compile it on your system, I suppose the ruby that is under /usr/bin is the system's and you are using macosx. The one located in /usr/local/bin is probably something you installed yourself and even maybe you don't even need to reinstall ruby 1.9.2. If that's so get you .bashrc in proper order by making sure /usr/local/bin comes before /usr/bin and you won't have to worry so much about which version you might be using. Create a ~/.bash_profile and put this in.
export PATH="/usr/local/bin:$PATH"
Expected output (more or less):
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/texbin
Others mentioned RVM. I used it, but I don't use it on a production server, I prefer a single sane ruby install to RVM. There is also rbenv and is seems much saner.
Final thought play around in your system remove symlink stuff, set your PATH variable or use RVM/rbenv.
Managing Ruby: Moving From RVM to rbenv
It's time to switch over, http://cantina.co/2011/10/08/managing-ruby-moving-from-rvm-to-rbenv/
So I was following the steps on Hivelogic to get ruby on rails setup on my machine. After compiling and installing, I used the which ruby command to double check it installed in the right place. It did not. I was able to install the Rails and MySQL gems though, but both POW and localhost:3000 don't work.
Is there anything wrong with having it in the usr/bin directory instead of usr/local/bin? My usr/local/bin is practically empty, but usr/bin has a ton of files in it.
Edit: I reinstalled ruby to usr/local/bin but now Rails won't install. Is it a problem that it's already installed in usr/bin?
That page is a few years old. The current best practice for Mac and Linux is to use rvm. You can see, even Hivelogic uses rvm now (though I'm not sure how I feel about installing it system wide).
Anything that recommends installing from source as the first option instead of a last-resort fallback is probably bad advice. It's better to install using a package manager like MacPorts or Homebrew both of which have current versions of Ruby 1.8 and 1.9.
MacPorts installs everything in /opt specifically to avoid conflict with system files. From time to time Apple will distribute an update that patches ruby and this can mess up anything you have in the way of dependencies if you've been using a modified /usr/bin/ruby. Generally the system ruby is supposed to be left as-is.
You can replace the "compile ruby" step with an installer like that and save yourself a lot of trouble in the future. Just be sure to have /opt/local/bin as one of the first items in your PATH just as you would for other solutions.
Since installing Ruby and Rails and some kind of database can be a confusing process, it seems like there should be a meta-installer to help you through the process.
So I finally managed to get rails installed in the correct spot. I had to change the line in my .profile to export PATH="/usr/local/bin:$PATH" and then do a sudo gem update --system after installing rubygems before rails could actually be installed.
RVM and Homebrew did not help at all.
EDIT: Since people have a problem with this answer, I'm giving an update. I have since installed RVM and am liking it, but only because I have a friend I ask all my questions to, as RVM is really confusing if you're not used to doing a lot on the command line. I needed help from him to install it because I didn't have any of the bash files, and thought they were hiding somewhere. If you're missing the bash files, just create them yourself. This took a long time to get working, but now I apparently have it setup right.