script/plugin says command not found when the file exists - ruby-on-rails

I'm trying to upgrade rails 2.x to rails 3.0.0.
I am following this guide (http://www.rails-upgrade-checklist.com/#3.0) and it says to download this rails upgrade tool:
script/plugin install git://github.com/rails/rails_upgrade.git
When I try that I get an error:
$ script/plugin install git://github.com/rails/rails_upgrade.git
-bash: script/plugin: Permission denied
$ sudo script/plugin install git://github.com/rails/rails_upgrade.git
Password:
sudo: script/plugin: command not found
$ ls script/
about dbconsole destroy performance process server spec_server
console delayed_job generate plugin runner spec spin
$
How do I get this to work, I'm stuck on such an early step :)

Related

Rails webpacker can't find node version from nvm

I'm getting this error when running rails server.
sh: 1: node: not found
sh: 1: nodejs: not found
Node.js not installed. Please download and install Node.js https://nodejs.org/en/download/
also when trying to install webpacker:install
sudo rails webpacker:install
sh: 1: node: not found
sh: 1: nodejs: not found
Node.js not installed. Please download and install Node.js https://nodejs.org/en/download/
I'm using nvm manage my node and it works fine.
test_app4 [master] node -v
v8.16.0
How can i get rails to find my node instance from nvm?
EDIT:
If i install node via apt-get. Rails finds that node version which is found with nodejs -v. Just not sure why it doesn't find the nvm version.

Unable to install rails. error: You don't have write permissions for the /usr/local/rvm/gems/ruby-2.6.3 directory

I installed ruby 2.6.3 using RVM. later when i try to install rails i am getting following error.
$ gem install rails -v 6.0.2.1
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /usr/local/rvm/gems/ruby-2.6.3 directory.
$ sudo gem install rails -v 6.0.2.1
sudo: unable to execute /usr/bin/gem: No such file or directory
That's because at some point you used sudo to install your rvm. So, the system will require sudo permission to install later gems
When you use command $ sudo gem install rails -v 6.0.2.1, you tell system to use normal directly installed ruby, not via rvm, so it warns you No such /user/bin/gem error
The solution for this is to change ownership of all files in the ~/.rvm directory to current account, as if you're using root account by following command
sudo chown -R $USER ~/.rvm

libxml issue when installing twilio-ruby gem

I've been running in circles trying to install the 'twilio-ruby' gem in my rails app to no avail. Every time I try to bundle install I receive errors around libxml. Below is a part of the error I'm receiving when I add 'twilio-ruby' to the gem-file and try to bundle install:
Errno::EACCES: Permission denied # rb_sysopen - /Users/George/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/libxml-ruby-3.0.0/HISTORY
An error occurred while installing libxml-ruby (3.0.0), and Bundler cannot continue.
Make sure that `gem install libxml-ruby -v '3.0.0'` succeeds before bundling.
Trying to gem install libxml-ruby results in the error below:
ERROR: While executing gem ... (Errno::EACCES)
Permission denied # rb_sysopen - /Users/George/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/libxml-ruby-3.0.0/HISTORY
Any help that points me in the right direction would be much appreciated.
to install correctly rbenv follow the instructions on github for your operating system (Mac or Linux)
rbenv installation
While to better understand this problem, it is connected to security issues. Mac and Linux are Unix based system, where the user logs in and can execute commands on his home directory ~/<user>. If you try to execute a command to run a script in another directory like the root directory / or /bin, you will get an authorization error and you will need to run the command with sudo that stands for system user do.
For this reason, with linux you configure the ~/.bash_profile file
Add ~/.rbenv/bin to your $PATH for access to the rbenv command-line utility.
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
Ubuntu Desktop note: Modify your ~/.bashrc instead of ~/.bash_profile.
Zsh note: Modify your ~/.zshrc file instead of ~/.bash_profile.
so that those command irb, gem, rake, rails when executed from the user they:
Search your PATH for an executable file named rake
Find the rbenv shim named rake at the beginning of your PATH
Run the shim named rake, which in turn passes the command along to rbenv
explanation of shims in rbenv
You can also solve easily this problem by running the command with sudo, but it is not reccommended, as you can read also from the below post where they have the same problem but with rvm,
Why do I get a "permission denied" error while installing a gem?

Permission Error When Trying To Install Rails (OSX)

I am new to programming and am trying to get rails installed on my terminal. I have been following instructions from a friend, installing the xcode command line tools, homebrew, git, rbenv, ruby-build, ruby gems, ruby, and postgres. But whenever, I try $gem install rails, I get the following:
Russell-Silvers-MacBook-Pro:~ Russell_Silver$ gem install rails
ERROR: While executing gem ... (Errno::EACCES)
Permission denied # rb_sysopen - /Users/Russell_Silver/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/rails-4.2.0/README.md
This is especially frustrating because when I run $gem list, it says I have rails 3.2.18. Which is peculiar, because when I run $rails v$, it tells me I have Rails 4.2.0.
When I try to use rails rails my new_app
Errno::EACCES: Permission denied # rb_sysopen - /Users/Russell_Silver/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/rails-4.2.0/README.md
An error occurred while installing rails (4.2.0), and Bundler cannot continue.
Make sure that `gem install rails -v '4.2.0'` succeeds before bundling.
run bundle exec spring binstub --all
/Users/Russell_Silver/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/bundler-1.8.3/lib/bundler/shared_helpers.rb:83: warning: Insecure world writable dir /Users/Russell_Silver in PATH, mode 040707
bundler: command not found: spring
Install missing gem executables with `bundle install`
Russell-Silvers-MacBook-Pro:~ Russell_Silver$ bundle install
/Users/Russell_Silver/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/bundler-1.8.3/lib/bundler/vendor/thor/shell/basic.rb:355: warning: Insecure world writable dir /Users/Russell_Silver in PATH, mode 040707
Could not locate Gemfile or .bundle/ directory
This is really frustrating, especially for someone new to programming such as myself, so I am seeking help from anybody who might know what is wrong.
Your rbenv installation was incorrectly installed as it had elevated privileges which caused your user account to not have write access to ~/.rbenv.
Issue the following command in order to take of ownership of the directory:
sudo chown -R Russell_Silver ~/.rbenv
Note that some users may have a different rbenv directory, e.g. /usr/local/var/rbenv. This would take the place of ~/.rbenv in the above command.

Error during Installing Rails in Ubuntu 10.04

First I installed rvm for multi-user using script
\curl -L https://get.rvm.io | sudo bash -s stable
and I added users to rvm group.
and rvm seems worked fine. so I installed ruby 1.9.3 and set 1.9.3 as default
and now I tried to install rails with command
gem install rails
It seems worked fine, but when fetching json-1.7.6.gem and an error occurs.
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
/usr/local/rvm/rubies/ruby-1.9.3-p374/bin/ruby extconf.rb
creating Makefile
make
sh: make: Permission denied
Gem files will remain installed in /usr/local/rvm/gems/ruby-1.9.3-p374/gems/json-1.7.6 for inspection.
Results logged to /usr/local/rvm/gems/ruby-1.9.3-p374/gems/json-1.7.6/ext/json/ext/generator/gem_make.out
So I thought it would be related with permission, so I tried
sudo gem install rails
but then this error occurs.
sudo: gem: command not found
What should I do?
use sudo as follows..
sudo gem install rails
Updated Answer:
our $PATH variable needs to include the exact path to your Ruby's bin directory. Adding a directory to the PATH does not include it's subfolders. Try adding the bin directory via:
export PATH=$PATH:/home/adam/.gem/ruby/1.8/bin
or if you installed the gem using sudo:
export PATH=$PATH:/usr/lib/ruby/gems/1.8/bin
You might want to add this to your .bashrc file, so that you don't have to set this manually every time your open up a new bash.
you can use rvmsudo to run sudo commands. But you should really be using Gemfiles to install gems using Bundler.

Resources