Issue with gems in RVM, Ruby and Rails installation - ruby-on-rails

I have been trying to get my dev environment setup on my computer for a number of days now, but without any luck. I've had more error messages than I could care to remember and my installation problems have been anything but consistent.
My current problem is unknown as I don't know where its stemming from.
When I try to check my gem version gem -v, the terminal locks up for a couple minutes and then gives me this output:
/Users/Riley/.rvm/bin/gem: line 6: /Users/Riley/.rvm/bin/gem: Argument list too long
/Users/Riley/.rvm/bin/gem: line 6: /Users/Riley/.rvm/bin/gem: Undefined error: 0
The entire contents of that file are as follows:
#!/usr/bin/env bash
if [[ -s "/Users/Riley/.rvm/environments/ruby-2.0.0-p0" ]]
then
source "/Users/Riley/.rvm/environments/ruby-2.0.0-p0"
exec gem "$#"
else
echo "ERROR: Missing RVM environment file: '/Users/Riley/.rvm/environments/ruby-2.0.0-p0'" >&2
exit 1
fi
And I don't have a clue what its supposed to be, if not that. Checking which ruby gives me:
/Users/Riley/.rvm/bin/ruby
And the problem really seems to come alive when I try to install rails, gem install rails:
ERROR: Loading command: install (LoadError)
cannot load such file -- openssl
ERROR: While executing gem ... (NoMethodError)
undefined method `invoke_with_build_args' for nil:NilClass
** This error has ceased to occur and is now replaced with the above "line 6" error for gem -v, however I'm sure it will show up again.
I have also tried all of this:
rvm get head --autolibs=3
rvm pkg remove
rvm reinstall all --force
and all the other renditions of solutions on SO and many other sites.
I would greatly appreciate someone helping me with this setup as I don't have any solution to my problem outside of google and SO.

The problem stemmed from my installation of Ruby. Apparently, as stated in this answer, "a non-LLVM version of GCC" is no longer included in the XCode command line tools.
Installing ruby with:
rvm install ruby --with-gcc=clang
Worked and I installed RVM, Ruby and Rails within about 10 minutes, despite it taking me a week of debugging and reinstalling otherwise.

Run rvm requirements and install all the dependencies as specified (openssl being one of them). It should fix your problem.

Related

Received odd RVM error in workspace, now rails commands aren't working

I just logged into my Ubuntu workspace on Cloud9. Upon logging in I saw an error.
RVM used your Gemfile for selecting Ruby, it is all fine - Heroku does
that too, you can ignore these warnings with 'rvm rvmrc warning ignore
/home/ubuntu/workspace/Simutronix/Gemfile'. To ignore the warning for
all files run 'rvm rvmrc warning ignore allGemfiles'.
Which I've not seen before and wasn't occurring when I last used the workspace. I then attempted to run the Rails server.
rails server -b $IP -p $PORT
I got an error message back.
bash: rails: command not found
I then tried to run bundle install which also came back with command not found.
ruby -v returns ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux].
What's likely to have happened to cause this to happen in between logins and what can I do to fix it?
Looks like Ubuntu can't find your Rails installation. Make sure you have Rails installed on your workspace by typing:
rails -v
If it is properly installed, It should return something like
Rails 5.0.2
(depending upon your Rails version.)
If you don't have Rails installed, you can install it by typing
gem install rails
You can append --no-doc to the above command if you don't want it to install documentation, thereby speeding up the installation process (That's totally up to you, though. It won't affect your installation in any other way. I promise!)
If this doesn't solve your problem, please update your answer with your Gemfile.
Likely the Ruby version defined in your Gemfile and/or .ruby-version changed, which means you will have to install bundler and bundle the gems again. Running this should solve the issue:
gem install bundler
bundle install

Gem installed but 'command not found'

I've installed a Ruby gem called wordmove to work with pushing and pulling my Wordpress sites but when I run wordmove commands I get the error command not found. I've done some research and I haven't come up with much, I've come to the conclusion based on what I've seen that my Ruby install is messed up.
I ran echo "$PATH" from my root and it returned the following:
/Library/Frameworks/Python.framework/Versions/3.4/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/Users/brettgolding/.rbenv/shims:/usr/local/bin:/user/local/sbin:/usr/local/mysql/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/MacGPG2/bin
I am a noob with the terminal so have no idea how to clean this mess up.
So you're working with rbenv. According to its README, you should run rbenv rehash after installing any gems that have an executable command. Also, run it anytime you install a new Ruby version.

Rails server giving Readline support error

I'm new to Ruby on Rails and I'm trying to start the RoR server. But when I run the command rails server it gives me the following error:
Sorry, you can't use byebug without Readline. To solve this, you need to
rebuild Ruby with Readline support. If using Ubuntu, try `sudo apt-get
install libreadline-dev` and then reinstall your Ruby.
bin/rails:6: warning: already initialized constant APP_PATH
/home/abraar/ror/bin/rails:6: warning: previous definition of APP_PATH was here
Usage: rails COMMAND [ARGS]
I'm using rbenv with Ruby 2.2.2 and Rails 4.2.1
I tried following the instructions on this blog post http://vvv.tobiassjosten.net/ruby/readline-in-ruby-with-rbenv/ but it's not working.
Any solutions?
Thanks!
To fix this (for OSX, tested on Sierra), run following command in your shell -
ln -s /usr/local/opt/readline/lib/libreadline.dylib /usr/local/opt/readline/lib/libreadline.6.dylib
July 2019 on Mac
I faced this same issue on my machine & running the following command solved it, note that even if you have version 8 of readline you still need to link to version 7 as shown:
ln -s /usr/local/opt/readline/lib/libreadline.dylib /usr/local/opt/readline/lib/libreadline.7.dylib
I solved the issue by (commands for mac with homebrew and rbenv):
installing readline brew install readline
reinstalling / recompiling ruby rbenv install 2.3.1
I was facing the following error:
Sorry, you can't use byebug without Readline
Reinstalling ruby resolved this for me (using rvm):
rvm reinstall 2.1.5
You can replace ruby version ie, 2.1.5 with the one you want to reinstall.
Add this to the development group of gem.
gem 'rb-readline'
https://github.com/deivid-rodriguez/byebug/issues/289#issuecomment-251383465
byebug is a gem used for debugging.
The new app generator for rails includes it by default in the development & test environments with the following lines:
group :development, :test do
<% if RUBY_ENGINE == 'ruby' -%>
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
I don't think it is important for a newcomer to be able to use it. I would recommend commenting out that line in the Gemfile, run bundle install and continue with your rails learning adventure.
I resolved it by follwing way
brew unlink readline
brew link readline --force
If you are in a hurry,
Open your byebug's history.rb
/Users/user/.rvm/gems/ruby-2.1.5#rails/gems/byebug-9.0.5/lib/byebug/history.rb
and comment out the following line,
require 'readline'
But, It is recommended to use byebug to debug.

Problems installing Ruby/Rails, even with RVM

So here is what happened:
I started working for a company and was given a macbook pro for work. I do customer support for Exceptional/Airbrake so i need to learn Ruby/Rails. So the laptop had a previous owner and i dont know what he did with it.
I tried to install Ruby and Rails and kept getting errors, then tried doing it with rvm, and i thought it was working as i could run irb and even execute a test program with ruby. I got tired of seeing the previous owners name on the command line so i changed the home folder and I am pretty sure this is where things got bad. I took the contents of rvm and everything and moved it to my User file from the old one then deleted the old one.
Everything seemed to still be working fine, but when I wanted to start working with rails as well, t it wouldnt work.So i figured i would just uninstall everything and start over, i tried rvm implode and removed all gems. when i run 'gem list', i get empty, and i cant find ruby anywhere but when i run irb, it still works. so i tried re-installing using rvm, but i keep getting errors.
The first error that occurs is:
No binary rubies available for: osx/10.7/x86_64/ruby-2.0.0-p0.
Continuing with compilation. Please read 'rvm mount' to get more information on binary rubies.
the second error is:
Error running 'env GEM_PATH=/Users/robertmroz/.rvm/gems/ruby-2.0.0-p0:/Users/robertmroz/.rvm/gems/ruby-2.0.0-p0#global:/Users/robertmroz/.rvm/gems/ruby-2.0.0-p0:/Users/robertmroz/.rvm/gems/ruby-2.0.0-p0#global GEM_HOME=/Users/robertmroz/.rvm/gems/ruby-2.0.0-p0 /Users/robertmroz/.rvm/rubies/ruby-2.0.0-p0/bin/ruby /Users/robertmroz/.rvm/src/rubygems-2.0.3/setup.rb', please read /Users/robertmroz/.rvm/log/ruby-2.0.0-p0/rubygems.install.log
and the last error is:
ERROR: Loading command: install (LoadError)
cannot load such file -- openssl
ERROR: While executing gem ... (NoMethodError)
undefined method `invoke_with_build_args' for nil:NilClass
I have gone through dozens of google searches, most of them leading me here, on each of these errors, and sometimes the certain error seems to be fixed, but in the end i cant get it to work. Should i just wipe the OS and start over, cause I have been trying to get this done for days now.
BTW, i dont know why it is installing 2.0.0 i thought rvm installed the latest version by default.
Before you blow out the system I'd:
Uninstall rvm (rvm implode, gem uninstall rvm) see this question
You should be left with just the base ruby. That should be the only one left.
Re-install rvm (\curl -L https://get.rvm.io without Rails).
Install the ruby version you want with rvm (rvm install 1.9.2) stay away from 2.0 for now.
Make sure your ruby version is installed and selected.
Install the rails version you want.
Hopefully that will straighten things out.
I also suffered from the same problems while installing Ruby , but after googling a lot I found the solution . Follow the below process :
If you have already installed anything uninstall all of that using Revo installer or by some other means , else go to step 2.
Next go to http://rubyinstaller.org/ and press the download button .
You will find a list of ruby versions , click on the latest version ( If you are running a 64 bit machine install the link with (x-64) else install the one without brackets .
Accept all the defaults and tick all the check boxes after downloading and setting it up , it will install in C:\ with name Ruby22 ( depending on its version )
Go to start menu type cmd , the use the command "cd C:\" without brackets , it will take you the C:\ drive
Check ruby -v , you should get the version number , else repeat the above process again .
Now use the command "gem install rails" , it will install all the rails requirements , this takes a lot of time .
Now use the command "gem install webrick" to install the web server
Now go to some browser , visit http://rubyinstaller.org/downloads/ , download the DevKit at the bottom of the page and extract it to some folder ( ex in C:\DevKit after creating the DevKit folder in C:\ )
Use the following commands in the same order
"ruby dk.rb init"
"ruby dk.rb install"
"gem install rdiscount --platform=ruby"
Rails is installed now .
Create a folder in C:\ for creating your rails apps and name the folder ( ex Rails _Apps ) use the command cd C:\Rails_apps to go there and use the command "rails new sample_rails_app" to create a Rails app with the name "sample_rails_app" .
It does a bunch of things and you are now able to use Ruby on Rails.
Ruby 2.0.0-p0 was recently released, so that is the latest version technically, although I kind of doubt you really want the latest version since it is so new and your company may still be running an older version like 1.9.3. Have you tried installing 1.9.3-p392 (the current 1.9.3 version)?
If you still get the error with 1.9.3, I would try the instructions shown on the RVM site:
$ rvm pkg install openssl
$ rvm reinstall 1.9.2 --with-openssl-dir=$rvm_path/usr

Problems with Rake When Using a Git Clone of a Rails Project with RVM

I have cloned a rails project from Ryan Bates (complex forms samples) and am having a problem with rake. I titled the question generally because I suspect it's an issue with my setup/usage rather than the project itself.
The project I am trying to use is:
I am using RVM on OSX and my default ruby is ruby-1.9.2-p290.
Here are the steps I am doing in a terminal (starting in a new empty directory):
git clone https://github.com/ryanb/complex-form-examples.git
--Created the project without error
The first time I did this, after I changed dir to the "complex-forms-examples", I got an RVM warning which I had not seen before. It was asking for some sort of permission which I granted. It does not do this anymore when I repeat the clone in a new empty directory.
The warning mentioned that there is an .rvmrc file in the directory. The contents are as follows (one line):
rvm 1.9.2#complex-form-examples --create
I then run 'bundle' and have no errors.
Then I try to run "rake db:migrate" and I get the following error:
-bash: /Users/ken/.rvm/gems/ruby-1.9.2-p290#global/bin/rake: /Users/ken/.rvm/rubies/ruby-1.9.2-p136/bin/ruby: bad interpreter: No
such file or directory
I get the same error when I run rake by itself or with any other parameter.
I have no ruby 1.9.2-p136 so I don't know why it is trying to use that ruby.
'rails s' is starting the server without error
I am only having problems with this project (i.e. rake is still working fine in my other rails projects).
Can anyone tell me what I'm missing?
Thanks
It could be broken migration/upgrade of ruby, try this:
rvm 1.9.2#global,1.9.2#complex-form-examples do gem pristine
rvm 1.9.2#global do gem pristine rake
make sure there is no error reported, in case of errors you need to pristine all gems manually (like in the second line)
it looks like you have issues with updating rvm, go this route:
rvm get head && rvm reload
rvm use 1.9.2#complex-form-examples --create --install
also make sure you trust .rvmrc properly (cd project dir first):
rvm rvmrc trust .
maybe not related but you might find this interesting: http://screencasts.org/episodes/how-to-use-rvm

Resources