I'm really frustrated two day trying to work with rails for first time but I got many errors right now when I try to get the rails version got te next:
➜ first_app $ pwd
/Users/ChrispazDev/rails_projects/first_app/first_app
➜ first_app $ rails -v
Bundler is using a binstub that was created for a different gem.
This is deprecated, in future versions you may need to `bundle binstub rails` to work around a system/bundle conflict.
Rails 4.2.3
➜ first_app $ cd ..
➜ first_app $ rails -v
/Users/ChrispazDev/.rvm/gems/ruby-2.2.1#update3tutorial/bin/rails:23:in `load': cannot load such file -- /Users/ChrispazDev/.rvm/gems/ruby-2.2.1#update3tutorial/gems/rails-4.2.3/bin/rails (LoadError)
from /Users/ChrispazDev/.rvm/gems/ruby-2.2.1#update3tutorial/bin/rails:23:in `<main>'
from /Users/ChrispazDev/.rvm/gems/ruby-2.2.1#update3tutorial/bin/ruby_executable_hooks:15:in `eval'
from /Users/ChrispazDev/.rvm/gems/ruby-2.2.1#update3tutorial/bin/ruby_executable_hooks:15:in `<main>'
➜ first_app
Sorry if it's something stupid but I'm really lost.
Mac OS 10.10.3
ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-darwin14]
Regards.
It appears that the install of Rails is messed up. The last error message comes from when you were at the path /Users/ChrisapzDev/rails_projects/first_app compared with the original message inside a sub-directory to this path.
Additionally notice that you have RVM installed so you may need to
Test the path that is being used for the invocation of rails using explicit ./rails -v to see what happens
Clean out the RVM Gemset rvm gemset empty
Reinstall rails in the context of the gemset you have allocated via RVM.
It is because of RVM, your ruby versions are messed ( Your system ruby, and ruby you installed with rvm). There is no need to uninstall RVM as it will help you to switch between your ruby versions.
Try using below code
rvm use system // for using system ruby
rvm use x.x.x // Here x.x.x is version of ruby
as rvm use 2.2.2
May be this tutorial will help you .
Related
I'm unable to run rails new SomeApp.
I receive the following error:
load': cannot load such file --
/home/captainawesome/.rvm/gems/ruby-2.2.0/gems/rails-4.2.0/bin/rails (LoadError)
Going through the path in: /home/captainawesome/.rvm/gems/ruby-2.2.0/gems/rails-4.2.0/bin/rails, the bin directory does not exist.
Also, please know I can still run the rails server and console but not rails new app.
My current setup
Ubuntu 14.04
ruby 2.2.0p0
rails 4.2.0
rvm 1.26.11
local server (not remote)
development environment
$ which rails
/home/captainawesome/.rvm/gems/ruby-2.2.0/bin/rails
$ rails -v
Bundler is using a binstub that was created for a different gem.
This is deprecated, in future versions you may need to "bundle binstub rails"
to work around a system/bundle conflict.
Rails 4.2.0
Please know this only works inside of a project.
$ which ruby
/home/captainawesome/.rvm/rubies/ruby-2.2.0/bin/ruby
$ ruby -v
ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]
$which rvm
/home/captainawesome/.rvm/bin/rvm
$ rvm use
Using /home/captainawesome/.rvm/gems/ruby-2.2.0
$ rvm -v
rvm 1.26.11 (master) by Wayne E. Seguin <wayneeseguin#gmail.com>, Michal Papis <mpapis#gmail.com> [https://rvm.io/]
Please advise on how to correct this.
Re-install Rails, and it will solve your error:
Here's how:
gem install rails
And try to use separate gemsets for your Rails applications, this will allow you to quickly and automatically change your Ruby version and associated gems when you do cd your_project_name. Here's how.
To add to Arslan Ali's correct answer, you can also avoid endless installation of documentation. If you're impatient like me, do:
gem install rails --no-ri --no-rdoc
However with impatience also comes haste and forgetfulness. Luckily you can make skipping docs the default using method described in this SO post: How to make --no-ri --no-rdoc the default for gem install?
Update to B. Bulpett's answer which is deprecated, the new way of installing without documentation is
gem install rails --no-document
When trying to update OpenSSL - I broke (seemingly) everything surrounding Ruby and Rails on my laptop. Even after uninstalling ruby and rails through gem uninstall and rvm removeI am still running into this error:
Drews-MacBook-Pro:bookstore drewwyatt$ rails server
bin/rails:3: undefined method `require_relative' for main:Object (NoMethodError)
Everything has been working fine for months until I went mucking around - the worse part is that I'm not even sure what I did to mess things up.
extra info
Drews-MacBook-Pro:bookstore drewwyatt$ ruby -v
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.3.0]
Drews-MacBook-Pro:bookstore drewwyatt$ which ruby
/Users/drewwyatt/.rvm/rubies/ruby-2.0.0-p247/bin/ruby
Drews-MacBook-Pro:bookstore drewwyatt$ rails -v
bin/rails:3: undefined method `require_relative' for main:Object (NoMethodError)
Drews-MacBook-Pro:bookstore drewwyatt$ which rails
/Users/drewwyatt/.rvm/rubies/ruby-2.0.0-p247/bin/rails
Drews-MacBook-Pro:bookstore drewwyatt$
update - installing without sudo
Drews-MacBook-Pro:~ drewwyatt$ gem install rails
Fetching: railties-4.0.0.gem (100%)
ERROR: While executing gem ... (Errno::EACCES)
Permission denied - /Users/drewwyatt/.rvm/gems/ruby-2.0.0-p247/bin/ruby_executable_hooks
Drews-MacBook-Pro:~ drewwyatt$
I fixed the problem by completely removing Rails, Ruby, and RVM altogether - then starting from scratch.
I don't remember all of the commands exactly, but it was something like:
sudo gem uninstall rails
sudo rvm remove 2.0
rvm implode
sudo chown -R drewwyatt: ~/.rvm/
rm -rf ~/.rvm
\curl -L https://get.rvm.io | bash -s stable --rails
rvm use 2.0
gem install rails
This came up for me after installing rails with Rails Composer. Seems like a problem with RVM selecting the ruby version, the trick was to simply navigate out and back into the folder.
$ cd ..
$ cd myapp
I was able to resolve this problem by simply running gem install rails.
This problem occurred when I cloned a pre-existing Rails 4 app. I am using ruby-2.0.0-p317, and an RVM gemset specific to this app. I ran the initial bundle install, but then could not run rails console without getting the error.
After running gem install rails, which used the cached copy in my app's gemset, the problem was resolved. Don't ask my why!
Try running bundle exec rails server instead of just rails server.
I was seeing this error because I had a conflicting version of the rails gem installed globally.
Prefixing commands with bundle exec ensures that you're using gems specified by your project's Gemfile.lock.
Similar to #ncherro, I got this using ruby filename.rb. Running
bundle exec ruby filename.rb
works.
I've been fighting with my Mac OS X 10.8 installed version of Ruby and tried to move to a .rvm install in order to keep everything up to date.
After going through all the documentation on the RVM website, here are some outcomes:
~$ which ruby
/Users/localadmin/.rvm/rubies/ruby-1.9.3-p327/bin/ruby
~$ ruby -v
ruby 1.9.3p327 (2012-11-10 revision 37606) [x86_64-darwin12.2.0]
~$ which rails
/usr/bin/rails
~$ rails -v
-bash: /usr/bin/rails: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby: bad interpreter: No such file or directory
I'm not exactly sure what's causing this. I'm expecting that Rails is trying to use the system Ruby version, which isn't what I set as default in RVM.
I've read that it could be a .gemrc problem, but I can't seem to find a .gemrc file in my home directory. I can't seem to find any references to rails in my .rvm directory, so I'm thinking maybe when I did "gem install rails", "gem" was actually the one affiliated with my system Ruby.
Sorry to answer my own question, and I'd be happy if it gets deleted, but the solution was fairly annoying.
I had been installing rails with:
sudo gem install rails
I guess this took me out of the userspace in which my RVM installation sat
gem install rails
installed rails properly and now I get "Rails 3.2.9" as the outcome to rails -v
Could anyone shine any light on why this happened?
When using RVM, you pretty much NEVER use sudo for anything. The only common exception to this I've found is when installing the Passenger module.
That means all operations you want to perform on or with gems, rubies, rubygems, or RVM itself should NOT be performed with sudo.
Also make sure to do rvm use [RUBY] --default to make certain you're always using a ruby other than the system ones.
Odd problem, trying to figure out what is going on here with my fresh install.
I installed Ruby 1.9.3 using homebrew. I installed Rails 3.2.0 using ruby gems. I then created a test application with rails new test_app to make sure everything looked okay in the test environment. Somehow, the rails environment is using 1.8.7 instead of 1.9.3.
When doing a ruby -v, I get this:
overcast:test_app joe$ ruby -v
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin11.2.0]
But when running rails s I get this:
overcast:test_app joe$ rails s
=> Booting WEBrick
=> Rails 3.2.0 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2012-01-21 23:21:35] INFO WEBrick 1.3.1
[2012-01-21 23:21:35] INFO ruby 1.8.7 (2010-01-10) [universal-darwin11.0]
And, obviously, when looking at the rails environment webpage at localhost:3000 I am showing 1.8.7 instead of 1.9.3. I've edited /etc/paths to have /usr/local/bin at the top based on some answers I've found here, but it doesn't seem to make a difference.
Any help would be greatly appreciated!
Addendum: The same situation happens when installing and attempting to use Ruby through RVM.
If you are running mac os x you have ruby 1.8 preinstalled. Use RVM or rbenv if you want to have more than one ruby version installed.
Homebrew not so bad :)
You may use rbenv. It is ruby version manager.
My success story for MAC OS X 10.8.2 is:
install Homebrew
change PATH in /etc/paths (/usr/local/bin need to be first)
install rbenv and ruby-build (it is plugin for rbenv) using homebrew
create ~/.profile with content:
export RBENV_ROOT=/usr/local/opt/rbenv
if which rbenv > /dev/null; then
eval "$(rbenv init -)"
fi
install last stable ruby version using rbenv install 1.9.3-p374
change default ruby version using rbenv global 1.9.3-p374
update gem using gem update --system (optional)
install rails gem install rails
...
Profit :)
bundle exec rails server
Should work just fine. It also worked for me to close the terminal and open a new one.
if you have multiple versions of ruby, I recommend you use RVM
Install it https://rvm.io/rvm/install
Use: https://github.com/wayneeseguin/rvm#usage
To view all versions of ruby use "rvm list"
and set default version "rvm --default version"
sudo update-alternatives --config gem
and select your verison!
I'm trying to get my computer (Mac OS X, running Leopard) running with the latest version of Rails. Before this, I had 2.3.5. I tried following some instructions a few days ago, but didn't seem to make much progress. Now, I can't do anything in Rails. You'll see what I mean in a sec.
Theoretically, I've got the latest versions of Ruby:
$ ruby -v
ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin9]
$ sudo ruby -v
Password:
ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin9]
But if I try to run Rails, I get this error message:
$ rails testapp03
Rails requires Ruby version 1.8.7 or later.
You're running 1.8.6 (2008-08-11); please upgrade to continue.
And if I try to see which version of Rails I'm using, I get the same:
$ rails -v
Rails requires Ruby version 1.8.7 or later.
You're running 1.8.6 (2008-08-11); please upgrade to continue.
In case these are useful:
$ which ruby
/opt/local/bin/ruby
$ sudo which ruby
Password:
/opt/local/bin/ruby
$ which rails
/usr/bin/rails
So, the question: What have I done, and what do I need to do to get Ruby / RubyGems / Rails up and running on my computer?
What does which gem return?
Probably, your Ruby installation points to /opt/local/bin/ while the gem command is still referencing /usr/bin/.
When you installed the Gem, the Gem was saved in /usr/bin/ and loads the original system Ruby.
I don't know how you installed Ruby 1.8.7, however I would suggest you to take a step further: remove all your Ruby versions (except the system one, of course) and try RVM.
Try executing this command /opt/local/bin/ruby -v from the command line and see what version of ruby that come out.
Next find out where is the ruby gems is located with whereis ruby. I assume it should near /opt/local/lib/ruby-x.x/gems/.... Also try find out whether rails is installed under those directories. If not, your rails might be still pointing to the old ruby.
Also check if you have /usr/bin/ruby? If so, what is the output of /usr/bin/ruby -v ?
If it exists and rails is pointing to that version, So you should uninstall that ruby and rails, and install the rails gem all over again with /opt/local/bin/ruby