I deleted some old versions of gems and now rails is broken - ruby-on-rails

So long story short I was running out of room on my dual booted ubuntu laptop. I decided to delete some older versions of gems to make some room which worked. Great, except now I can't get rails to work on my machine anymore - rails console and rails server is failing. This is the error I see when I type in rails s;
jmtoporek#jmtoporek-laptop:~/rails/pskr2$ rails s
/home/jmtoporek/.rvm/gems/ruby-1.9.2-p180/gems/hpricot-0.8.6/lib/fast_xs.so: [BUG] Segmentation fault
ruby 1.8.7 (2010-01-10 patchlevel 249) [i486-linux]
/usr/bin/rails: line 104: 4807 Aborted /usr/bin/ruby /usr/share/rails/railties/bin/rails ${OVERWRITE_OPTION} "${RAILS_PKG_DESTINATION}" "${INTERNAL_OPTIONS}" -d $DATABASE
ln: target `/home/jmtoporek/rails/pskr2/s/vendor/' is not a directory: No such file or directory
ln: creating symbolic link `/home/jmtoporek/rails/pskr2/s/vendor/rails': No such file or directory
ln: creating symbolic link `/home/jmtoporek/rails/pskr2/s/doc/api': No such file or directory

I suppose reinstalling rails should be enough, because it installs several gems to run properly. Simply run gem install rails and see if it works again.
Also, if you use RVM, you can use a different installation executing something like this:
rvm use ruby-1.9.3-p286#rails328 --create --default
..and then, installing rails again:
gem install rails
Just remember this last solution requires you to install all other gems as well.

I reinstalled railties - despite the fact that the gem was already installed something must have gotten messed up. I reinstalled railties, which fixed the issue. I wish I had looked closer at the error message. It appears that there is a copy of railties inside the rails gem directory.

Related

Error trying to bundle install a ruby new generated project

I just started in Ruby, so after a lookup on internet I installed it using rvm. The version of ruby is 2.6.3. This is the output for ruby -v:
ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-linux]
I also installed Rails using gem install rails and get the version 6.0.2.1.
After that I created a project called blog using rails new blog, the project was created and in the directory I run bundle install and get the following error message:
There was an error while trying to write to
`/home/ramon/.bundle/cache/compact_index/rubygems.org.443.29b0360b937aa4d161703e6160654e47/versions`.
It is likely that you need to grant write permissions for that path.
After that I run sudo bundle install and get this error:
Your Ruby version is 2.7.0, but your Gemfile specified 2.6.3
But my Ruby version is already 2.6.3.
After searching for answers on internet I tried these solutions:
sudo gem update bundler
sudo gem install bundler
sudo gem install rails
But all of this returned the same error:
/usr/bin/env: ‘ruby’: No such file or directory
Then I run which ruby and got this: /home/ramon/.rvm/rubies/ruby-2.7.0/bin/ruby
and added this line do .bashrc:
export PATH=$PATH:/home/ramon/.rvm/rubies/ruby-2.7.0/bin/ruby
But still got the error.
I tried changing this line in /etc/login.defs to:
ENV_PATH PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/$
And /etc/environment to:
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/$
But I dont know what to do anymore, tried every solution on internet and nothing works.
One thing I tried was running which ruby as superuser, and I got nothing.
Maybe it is a PATH problem or a permission problem. But I dont know anymore what to do.
I use lubuntu 19.04.
I think you have two versions of Ruby , so you may try this:
rvm --default use [correct version number]
Create a new file .ruby-version in the main folder of project and put ruby version inside:
2.6.3
or
2.7.0
because I don't know which Ruby version you want do use.
Save and go to the console and do this:
cd ..
cd blog (your project name)

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

Rails - Closed terminal and rebooted machine - now bash tells me rails isn't installed

Running OSX Mavericks, ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-darwin13.0], rvm 1.25.23 (master), and rails-4.1.0 (allegedly)
I'm working through the railsapps.org book on learning rails and made it about 1/2 way through yesterday. When I stopped for the day, I closed out iTerm2 and shut off the Macbook Pro. Today, I powered up, opened iTerm, navigated to my working directory (~/rubyonrails/learn-ruby) and entered rails -v.
I see this:
`Rails is not currently installed on this system. To get the latest version, simply type:
$ sudo gem install rails
You can then rerun your "rails" command.`
So I run sudo gem install rails and it shows that it has installed rails-4.1.0. Now rails -v still gives me the same error message above.
I tried also running rvm use ruby-2.1.1#learn-rails first and I still get the error message.
So I'm a little stuck and I can't figure out what to do to get rails working. Also, how do I go about setting up the bash environment such that I don't have to go through this each time? It would be nice to nav to my working directory and just start work without having to do a bunch of re-installation and reconfiguration each time.
Regards,
Jeff
please type in your shell:
$ bash --login
and then repeat your commands.
rails -v
Also try to call it with the full path:
like:
/your/path/to/rails -v
I think that the shell just doesn't know where rvm/rails etc is located.
You can solve this by entering:
$ source ~/.rvm/scripts/rvm
When you switch to the ruby-2.1.1#learn-rails ruby/gemset combo, and do gem list, what do you see?
The way people usually use rvm is to have every project folder specify the ruby & gemset it uses (they don't all have to be different). This is done with files called .ruby-version and .ruby-gemset. These should contain, in your case, ruby-2.1.1 and learn-rails respectively.
Set these if you haven't already, then leave the folder and enter it again. Then do bundle install to install the gems for the project into the rvm/gemset combo.
Your problem is that you ran
sudo gem install rails
The error message telling you to do this comes from your system Ruby, which doesn't know that you want to use RVM.
RVM installs gems into your user-space directory. By using sudo, you're bypassing this and installing it into (effectively) the superuser space, i.e. globally.
If you instead just run
gem install rails
then you'll be using RVM's copy of the gem utility rather than the globally installed version.

Rails app cant detect local gems

This is a very odd one and I'm not sure how to proceed.
Basically, I am able to install gems and use them normally within any folder except those created with rails. It's very very odd. It's difficult to explain so maybe this console output will explain
passenger#rubyserve:~/railsapps$ ls
app test_application testing
passenger#rubyserve:~/railsapps$ rails -v
Rails 3.2.2
passenger#rubyserve:~/railsapps$
passenger#rubyserve:~/railsapps$
passenger#rubyserve:~/railsapps$ cd app/
passenger#rubyserve:~/railsapps/app$ ls -a
. app config.ru doc Gemfile.lock lib public README.rdoc test vendor
.. config db Gemfile .gitignore log Rakefile script tmp
passenger#rubyserve:~/railsapps/app$
passenger#rubyserve:~/railsapps/app$
passenger#rubyserve:~/railsapps/app$ rails -v
The program 'rails' is currently not installed. To run 'rails' please ask your administrator to install the package 'rails'
passenger#rubyserve:~/railsapps/app$
It makes bugger all sense. When outside my rails folder, I can call rails to make a new application but once within, rails isn't detected. This is the same for all gems including bundler.
My first thought was that somehow, rails had some specific gem folder hidden away, so I done my gem install from within the rails project, however this didn't work either.
Any thoughts?
My setup is ubuntu server 10.10 (I know, i know)
Ruby 1.9.2
gem 1.8.17
and I'm using the latest rvm from wayneeseguin.enter code here
This type of problem some time occurs i think u can save a lot of time by installing and using RVM
After installing RVM create gemset directory every time whenever you create separate project. e.g you create application blog first you create gemset directory with giving this command
rvm gemset create blog
then you should use this gemset directory and also ruby version as well e.g you have install ruby 1.9.2 then use this command
rvm use ruby-1.9.2#blog
after that go into directory of blog application and install this gem
gem install bundler
and also then bundle install. so all local gem will be installed into this blog directory under rvm and there will be no conflicts will be appear.But keep one thing in mind if your platform is ubuntu then this will work

SQLite3 stopped working

I have been working on an ruby app for a while, and today starting up my server via "rails server" I now get this:
/Users/Ross/rails_projects/splash/json/ruby/1.9.1/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:239:in `require': no such file to load -- sqlite3/sqlite3_native (LoadError)
What I changed before this, was I installed the curb and json gems. The funny thing is it still works on Heroku, just not my local machine. So it must be environmental. However, I cannot figure out what broke and why.
Still stuck, noticed if I load up irb:
MacBook-Pro:splash Ross$ irb
ruby-1.9.2-p136 :001 > require 'sqlite3'
=> true
ruby-1.9.2-p136 :002 >
So why does that work and not the rails server? I even tried to reinstall rails. Nothing. Path issue?
Update: Still not working, tried another of solutions: building from source, uninstall, reinstall, upgrade rails, etc. The message has changed slightly:
/Volumes/Macintosh HD/Users/Ross/rails_projects/splash/json/ruby/1.9.1/gems/sqlite3-1.3.3/lib/sqlite3.rb:6:in `require': no such file to load -- sqlite3/sqlite3_native (LoadError)
I really need help, this is really killing my productivity.
Try this, install homebrew and rvm as per my blog post here.
$ rvm --default 1.9.2
It'll spit out a comment giving you the install command to grab the latest ruby. Then repeat the above command to set it. You can test this by doing
$ ruby -v
It should show you something similar to the following, although I'm using 1.8.7
$ ruby -v
ruby 1.8.7 (2011-02-18 patchlevel 334) [i686-darwin10.2.0]
Now simply reinstall rails gem install rails and do bundle install. By using rvm, and hopefully a newer version of ruby, it'll setup a whole new space for you to test out a new deploy. Hopefully you won't get the same issue again. Keep us posted :)
Thanks for the response Mike. Funny thing was it didn't work. After I did it, I got a message about curl was missing. So I installed it and the sqlite3 error popped up immediately again.
A ton more Googling and I found an post about installing sqlite3 through RVM.
so I did a:
rvm gem install sqlite3
then I did:
rm -rf .bundle && bundle install
Then it started working. I'm not sure if it was the deleting the bundle or installing through rvm, but either way it's working again.

Resources