rails: Getting started steps don't work on Ubuntu 18.04 LTS
Steps to reproduce
I’m new to both Ruby and Rails so I just wanted to try it out. I’m following the steps on https://github.com/basecamp/rails#getting-started
First I got
$ gem install rails
Fetching: concurrent-ruby-1.1.9.gem (100%)
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /var/lib/gems/2.5.0 directory.
Since it’s a permission issue, I thought maybe I should run as root so I try with sudo
$ sudo gem install rails
[sudo] password for dskloet:
Fetching: concurrent-ruby-1.1.9.gem (100%)
Successfully installed concurrent-ruby-1.1.9
Fetching: i18n-1.8.10.gem (100%)
Successfully installed i18n-1.8.10
Fetching: tzinfo-2.0.4.gem (100%)
Successfully installed tzinfo-2.0.4
Fetching: zeitwerk-2.4.2.gem (100%)
Successfully installed zeitwerk-2.4.2
Fetching: activesupport-6.1.4.gem (100%)
Successfully installed activesupport-6.1.4
Fetching: rack-2.2.3.gem (100%)
Successfully installed rack-2.2.3
Fetching: rack-test-1.1.0.gem (100%)
Successfully installed rack-test-1.1.0
Fetching: racc-1.5.2.gem (100%)
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
current directory: /var/lib/gems/2.5.0/gems/racc-1.5.2/ext/racc/cparse
/usr/bin/ruby2.5 -r ./siteconf20210706-6968-airftl.rb extconf.rb
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h
extconf failed, exit code 1
Gem files will remain installed in /var/lib/gems/2.5.0/gems/racc-1.5.2 for inspection.
Results logged to /var/lib/gems/2.5.0/extensions/x86_64-linux/2.5.0/racc-1.5.2/gem_make.out
Since it still doesn’t work, I copy the error message “ERROR: Failed to build gem native extension” into Google and find this so I try
sudo apt-get install ruby-dev
and once again
$ gem install rails
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /var/lib/gems/2.5.0 directory.
and once again with sudo
$ sudo gem install rails
Building native extensions. This could take a while...
Successfully installed racc-1.5.2
Fetching: nokogiri-1.11.7-x86_64-linux.gem (100%)
Successfully installed nokogiri-1.11.7-x86_64-linux
Fetching: crass-1.0.6.gem (100%)
Successfully installed crass-1.0.6
Fetching: loofah-2.10.0.gem (100%)
Successfully installed loofah-2.10.0
Fetching: rails-html-sanitizer-1.3.0.gem (100%)
Successfully installed rails-html-sanitizer-1.3.0
Fetching: rails-dom-testing-2.0.3.gem (100%)
Successfully installed rails-dom-testing-2.0.3
Fetching: builder-3.2.4.gem (100%)
Successfully installed builder-3.2.4
Fetching: erubi-1.10.0.gem (100%)
Successfully installed erubi-1.10.0
Fetching: actionview-6.1.4.gem (100%)
Successfully installed actionview-6.1.4
Fetching: actionpack-6.1.4.gem (100%)
Successfully installed actionpack-6.1.4
Fetching: activemodel-6.1.4.gem (100%)
Successfully installed activemodel-6.1.4
Fetching: activerecord-6.1.4.gem (100%)
Successfully installed activerecord-6.1.4
Fetching: globalid-0.4.2.gem (100%)
Successfully installed globalid-0.4.2
Fetching: activejob-6.1.4.gem (100%)
Successfully installed activejob-6.1.4
Fetching: mini_mime-1.1.0.gem (100%)
Successfully installed mini_mime-1.1.0
Fetching: mail-2.7.1.gem (100%)
Successfully installed mail-2.7.1
Fetching: actionmailer-6.1.4.gem (100%)
Successfully installed actionmailer-6.1.4
Fetching: nio4r-2.5.7.gem (100%)
Building native extensions. This could take a while...
Successfully installed nio4r-2.5.7
Fetching: websocket-extensions-0.1.5.gem (100%)
Successfully installed websocket-extensions-0.1.5
Fetching: websocket-driver-0.7.5.gem (100%)
Building native extensions. This could take a while...
Successfully installed websocket-driver-0.7.5
Fetching: actioncable-6.1.4.gem (100%)
Successfully installed actioncable-6.1.4
Fetching: marcel-1.0.1.gem (100%)
Successfully installed marcel-1.0.1
Fetching: activestorage-6.1.4.gem (100%)
Successfully installed activestorage-6.1.4
Fetching: actionmailbox-6.1.4.gem (100%)
Successfully installed actionmailbox-6.1.4
Fetching: actiontext-6.1.4.gem (100%)
Successfully installed actiontext-6.1.4
Fetching: thor-1.1.0.gem (100%)
Successfully installed thor-1.1.0
Fetching: method_source-1.0.0.gem (100%)
Successfully installed method_source-1.0.0
Fetching: railties-6.1.4.gem (100%)
Successfully installed railties-6.1.4
Fetching: bundler-2.2.21.gem (100%)
Successfully installed bundler-2.2.21
Fetching: sprockets-4.0.2.gem (100%)
Successfully installed sprockets-4.0.2
Fetching: sprockets-rails-3.2.2.gem (100%)
Successfully installed sprockets-rails-3.2.2
Fetching: rails-6.1.4.gem (100%)
Successfully installed rails-6.1.4
Parsing documentation for racc-1.5.2
Installing ri documentation for racc-1.5.2
Parsing documentation for nokogiri-1.11.7-x86_64-linux
Installing ri documentation for nokogiri-1.11.7-x86_64-linux
Parsing documentation for crass-1.0.6
Installing ri documentation for crass-1.0.6
Parsing documentation for loofah-2.10.0
Installing ri documentation for loofah-2.10.0
Parsing documentation for rails-html-sanitizer-1.3.0
Installing ri documentation for rails-html-sanitizer-1.3.0
Parsing documentation for rails-dom-testing-2.0.3
Installing ri documentation for rails-dom-testing-2.0.3
Parsing documentation for builder-3.2.4
Installing ri documentation for builder-3.2.4
Parsing documentation for erubi-1.10.0
Installing ri documentation for erubi-1.10.0
Parsing documentation for actionview-6.1.4
Installing ri documentation for actionview-6.1.4
Parsing documentation for actionpack-6.1.4
Installing ri documentation for actionpack-6.1.4
Parsing documentation for activemodel-6.1.4
Installing ri documentation for activemodel-6.1.4
Parsing documentation for activerecord-6.1.4
Installing ri documentation for activerecord-6.1.4
Parsing documentation for globalid-0.4.2
Installing ri documentation for globalid-0.4.2
Parsing documentation for activejob-6.1.4
Installing ri documentation for activejob-6.1.4
Parsing documentation for mini_mime-1.1.0
Installing ri documentation for mini_mime-1.1.0
Parsing documentation for mail-2.7.1
Installing ri documentation for mail-2.7.1
Parsing documentation for actionmailer-6.1.4
Installing ri documentation for actionmailer-6.1.4
Parsing documentation for nio4r-2.5.7
Installing ri documentation for nio4r-2.5.7
Parsing documentation for websocket-extensions-0.1.5
Installing ri documentation for websocket-extensions-0.1.5
Parsing documentation for websocket-driver-0.7.5
Installing ri documentation for websocket-driver-0.7.5
Parsing documentation for actioncable-6.1.4
Installing ri documentation for actioncable-6.1.4
Parsing documentation for marcel-1.0.1
Installing ri documentation for marcel-1.0.1
Parsing documentation for activestorage-6.1.4
Installing ri documentation for activestorage-6.1.4
Parsing documentation for actionmailbox-6.1.4
Installing ri documentation for actionmailbox-6.1.4
Parsing documentation for actiontext-6.1.4
Installing ri documentation for actiontext-6.1.4
Parsing documentation for thor-1.1.0
Installing ri documentation for thor-1.1.0
Parsing documentation for method_source-1.0.0
Installing ri documentation for method_source-1.0.0
Parsing documentation for railties-6.1.4
Installing ri documentation for railties-6.1.4
Parsing documentation for bundler-2.2.21
Installing ri documentation for bundler-2.2.21
Parsing documentation for sprockets-4.0.2
Installing ri documentation for sprockets-4.0.2
Parsing documentation for sprockets-rails-3.2.2
Installing ri documentation for sprockets-rails-3.2.2
Parsing documentation for rails-6.1.4
Installing ri documentation for rails-6.1.4
Done installing documentation for racc, nokogiri, crass, loofah, rails-html-sanitizer, rails-dom-testing, builder, erubi, actionview, actionpack, activemodel, activerecord, globalid, activejob, mini_mime, mail, actionmailer, nio4r, websocket-extensions, websocket-driver, actioncable, marcel, activestorage, actionmailbox, actiontext, thor, method_source, railties, bundler, sprockets, sprockets-rails, rails after 40 seconds
32 gems installed
OK, this appears to have done something. So I continue the guide:
$ rails new myapp
-bash: /usr/local/bin/rails: Permission denied
So I check the permission:
$ ls -l /usr/local/bin/rails
-rwx------ 1 root root 604 Jul 6 12:44 /usr/local/bin/rails
OK, that’s weird. So I fix the permissions and try again:
$ sudo chmod a+rx /usr/local/bin/rails
$ rails new myapp
Traceback (most recent call last):
2: from /usr/local/bin/rails:23:in `<main>'
1: from /usr/lib/ruby/2.5.0/rubygems.rb:308:in `activate_bin_path'
/usr/lib/ruby/2.5.0/rubygems.rb:289:in `find_spec_for_exe': can't find gem railties (>= 0.a) with executable rails (Gem::GemNotFoundException)
I tried searching for the error message but found very few results.
I’m not sure how to continue.
System configuration
Rails version: 6.1.4
Ruby version: 2.5.1p57
OS: Ubuntu 18.04 LTS.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 22 (13 by maintainers)
This is ultimately not about tech support for @dskloet, but about how we recommend that beginning Rails devs install Ruby and Rails on Ubuntu and other linux distros. I believe that instead of linking to ruby-lang.org or saying “there are so many options, apt, yum, from source, rvm, rbenv etc. do whatever works for you”, the Rails community should pick one method, explain it in detail, in the Rails guides without delegating to other sites, and then in a footnote mention the other installation methods and why you’d want to use them.
After running
rvm reset
it seems to work.I agree. While I certainly appreciate the tech support, the reason for reporting the issue is to get the documentation improved. And hopefully my struggles can help guide the improvements.
Thanks, with the askubuntu.com link I was able to remove a bad Ubuntu 18 package and then successfully apt install. But after the
gem install
step, therails new
step failed.There seems to be some kind of version mismatch where it expects me to have version 2.5 where I only have version 2.7?