Failed to install Rails on yosemite - ruby-on-rails

I installed Ruby via rbenv. Currently, my pc has ruby 2.1.2p95 version installed. I have just started development in rails. So, don't know much about it.
But, I get some kind of error when I installed it.
$gem install rails -v 4.2.0
ERROR: Loading command: install (LoadError)
cannot load such file -- zlib
ERROR: While executing gem ... (NoMethodError)
undefined method `invoke_with_build_args' for nil:NilClass

Did you run rbenv rehash after installing that version of ruby? Perhaps your PATH is pointing to the wrong gem command?

I've run into something similar.
Try
xcode-select --install
Than perhaps give this a go if it still doesn't work:
rbenv uninstall 2.1.2p95
rbenv install 2.1.2p95

Related

bundler always not found when switched ruby version

i am using rvm and my default ruby is the latest Ruby , but i want to swith ruby version to 2.3.8
and after i run rvm use ruby2.3.8 and i want to run bundle install it said bundle not found, and then i tried to install bundle gem install bundler
then error i got is:
ERROR: Loading command: update (LoadError)
cannot load such file -- openssl
ERROR: While executing gem ... (NoMethodError)
undefined method `invoke_with_build_args' for nil:NilClass
i already re install rvm and read some question about that error on this SO to get openssll ( my openssl already installed by brew ) such this question
is there any way to solve this?

How can I install using gem when I keep getting this zlib error?

I recently installed rails 4.1.8 from the repos in ubuntu. I installed ruby 2.0.0. I want to update to rails 4.2.0. I rvm'd to ruby 2.0.0. I try to update rails using
gem install rails -v 4.2.0
but receive this error
ERROR: Loading command: install (LoadError)
cannot load such file -- zlib
ERROR: While executing gem ... (NoMethodError)
undefined method `invoke_with_build_args' for nil:NilClass
zlib1g-dev is already installed. I'm not sure what to do.
Thanks
I decided to simply uninstall everyting, a la
aptitude purge rails
Then start from scratch using this guide

undefined method `require_relative' for main:Object (NoMethodError)

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.

Rails 4 beta1 install error

Im having trouble getting the Rails 4 beta installed. I used RVM to install Ruby 2.0.0 and that seems to have succeeded ok. Here is the error I get when attempting to install the Rails gem;
$ gem install rails --version 4.0.0.beta1 --no-ri --no-rdoc
ERROR: Loading command: install (LoadError)
cannot load such file -- openssl
ERROR: While executing gem ... (NoMethodError)
undefined method `invoke_with_build_args' for nil:NilClass
Re-installing your RVM rubies with the latest versions should enable you to load all the dependencies required to install Rails:
rvm get head --autolibs=3
rvm pkg remove
rvm reinstall all --force

Installing Ruby On Rails - Issues with gem (and no RVM)

I'm having this issue whenever i run "gem install rails":
usr/local/lib/ruby/1.9.1/yaml.rb:56:in `<top (required)>':
It seems your ruby installation is missing psych (for YAML output).
To eliminate this warning, please install libyaml and reinstall your ruby.
ERROR: Loading command: install (LoadError)
cannot load such file -- zlib
ERROR: While executing gem ... (NameError)
uninitialized constant Gem::Commands::InstallCommand
Ruby and Rubygems were both installed from source. I've installed libyaml from source and from apt-get. I'm running ubuntu 12.04. I am NOT running RVM as far as I know (trying "rvm" returns "bla bla bla not installed apt-get". I'm pretty sure this speaks of 2 separate issues but I need solutions to both. Thanks.
RVM is best tool for easily install, manage, and work with multiple ruby environments.
https://rvm.io/rvm/install/ follow the instructions in this link to get RVM working.
Then you should install 'libtool' before you install 'libyaml'.
sudo apt-get install libtool
rvm pkg install libyaml
rvm reinstall 1.9.3
these commands are using for installing libyaml.
After installing this you can install rails using
gem install rails

Resources