0

I'm trying to create a new user form my rails application. I already ran psql -p 5432 -h localhsot -U postgres and created a new user. Then I added the user with sudo adduser user_name and afterwards changed to the user with sudo su user_name.

This works, but when I try to create a new app with rails new app -d postgresql, I'm getting the error “command rails not found”.

When I try to install the rails command with apt install ruby-railties, I'm getting the following error.

E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
  • 3
    It must be run as root e.g. sudo apt install ruby-railties – Rui F Ribeiro Apr 27 at 14:22
  • 2
    Pro tip: you don't need sudo su user_name, you can just do sudo -u user_name. – terdon Apr 27 at 14:33
  • 2
    “are you root?” – ctrl-alt-delor Apr 27 at 16:56
0

run as root : sudo apt install ruby-railties

0

If you created a new user, and plan to install things as that user, you will have to grant them root privileges first in the /etc/sudoers file. The following is an example of the sudoers file if you plan to give this user full root privilege. It is not best practice if you want to limit the users abilities

# User privilege specification
root ALL=(ALL:ALL) ALL
user_name ALL=(ALL:ALL) ALL

After you do that you can run:

sudo apt install ruby-railties (as the new user)

and enter the new users password right after that

[sudo] password for user_name:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.