Reputation: 13
Using Ubuntu, I ran the command
rvm use 2.7.3
I then ran
sudo rake db:create
and was greeted by the error
Your Ruby version is 2.7.0, but your Gemfile specified 2.7.3
Am I doing something wrong here? I have been battling with this for hours and have no idea how to proceed
Upvotes: 0
Views: 58
Reputation: 34338
The $PATH
variable when using sudo
is not the same as the $PATH
for your non-sudo user. Because RVM works by modifying $PATH
, the RVM modifications are lost when you invoke sudo
. That's why RVM stops working with sudo
.
If you really need to run something as root using RVM, then you can try it with rvmsudo
instead.
You can read more here:
rvmsudo vs sudo?
Also check the manual for rvmsudo
:
https://rvm.io/integration/sudo
However in your case it's better to adjust access to the database, so that root privileges are not needed for Rails to connect to the DB.
Upvotes: 1