Reputation: 621
I am trying to install Ruby on Rails on a Linux machine in my home directory (without root access). My ruby version is ruby 2.1.5p273 (2014-11-13) [x86_64-linux-gnu]
. So far I was able to:
$ gem install --user-install rails
which apparently has installed rails
into ~/.gem/ruby/2.1.0/bin/rails
:
$ ./.gem/ruby/2.1.0/bin/rails --version
Rails 4.2.6
But then it fails to create the application:
$ ~/.gem/ruby/2.1.0/bin/rails new myapp
create
create README.rdoc
create Rakefile
create config.ru
create .gitignore
create Gemfile
create app
create app/assets/javascripts/application.js
create app/assets/stylesheets/application.css
create app/controllers/application_controller.rb
create app/helpers/application_helper.rb
create app/views/layouts/application.html.erb
create app/assets/images/.keep
create app/mailers/.keep
create app/models/.keep
create app/controllers/concerns/.keep
create app/models/concerns/.keep
create bin
create bin/bundle
create bin/rails
create bin/rake
create bin/setup
create config
create config/routes.rb
create config/application.rb
create config/environment.rb
create config/secrets.yml
create config/environments
create config/environments/development.rb
create config/environments/production.rb
create config/environments/test.rb
create config/initializers
create config/initializers/assets.rb
create config/initializers/backtrace_silencers.rb
create config/initializers/cookies_serializer.rb
create config/initializers/filter_parameter_logging.rb
create config/initializers/inflections.rb
create config/initializers/mime_types.rb
create config/initializers/session_store.rb
create config/initializers/wrap_parameters.rb
create config/locales
create config/locales/en.yml
create config/boot.rb
create config/database.yml
create db
create db/seeds.rb
create lib
create lib/tasks
create lib/tasks/.keep
create lib/assets
create lib/assets/.keep
create log
create log/.keep
create public
create public/404.html
create public/422.html
create public/500.html
create public/favicon.ico
create public/robots.txt
create test/fixtures
create test/fixtures/.keep
create test/controllers
create test/controllers/.keep
create test/mailers
create test/mailers/.keep
create test/models
create test/models/.keep
create test/helpers
create test/helpers/.keep
create test/integration
create test/integration/.keep
create test/test_helper.rb
create tmp/cache
create tmp/cache/assets
create vendor/assets/javascripts
create vendor/assets/javascripts/.keep
create vendor/assets/stylesheets
create vendor/assets/stylesheets/.keep
run bundle install
There was an error while trying to write to `/var/lib/gems/2.1.0`. It is likely that you need to
grant write permissions for that path.
run bundle exec spring binstub --all
bundler: command not found: spring
Install missing gem executables with `bundle install`
Does rails require root access??
Thanks!
Upvotes: 3
Views: 2668
Reputation: 9485
A typical development environment is set up with RVM (or rbenv
, never tried it) and is contained entirely in your home folder: Ruby interpreter (possibly more than one!), its gems and configuration. For that you don't need root access.
When installing Ruby via RVM, you might get a prompt for installing dependencies required to compile Ruby from sources. That's one case. (And, as it turns out, this may fail if sudo
is not available, and it might be, so see this question for possible alternatives)
You might occasionally need root access for installing development libraries needed to compile native extensions for certain gems. For instance, for gem pg
you'll need libpq-dev
on Debian and derivatives (Ubuntu, Mint, etc.). While you could try downloading the sources to your home folder and point the compiler in that direction, that takes time. So that's two cases.
In your specific case rails
has done the job just fine: it generated the template, it just failed to bundle install
the template's dependencies. It uses whatever gem directory is default for RubyGems. Seeing that it's /var/lib/gems/2.1.0
, I'm guessing you're using system-wide Ruby. This isn't ideal for development as you might want to switch back and forth between different interpreter versions (or even implementations, such as Rubinius), use a version manager constrained to your home folder.
Not that you can do nothing else. Try cd
ing into the generated folder and running:
bundle --help install
There are many options, you see. --path
or even --standalone
can probably save you here, it overrides gem installation path and remembers the fact that it's overridden, so it knows where to look for gems.
Anyway, once the application is set up and dependencies are resolved and installed, you won't need root access for neither running it (on non-privileged ports, of course) or setting up another application, since any necessary system-wide dependencies will already be installed by then.
Upvotes: 3
Reputation: 2597
As I know, Ruby on Rails application require root access by default for install gems. Possible it may be configured, but there is more simple solution - Ruby Version Manager or something similar.
Rvm installs ruby gems in user's home directory and root access doesn't required for gems installing. Excepts unnecessary root Rvm allows to run different Ruby environments (eg different Ruby or RoR versions) in one user profile.
And look how to install Rvm without root access, look eg here, here or find it yourself
Upvotes: 1