mohsin tahir sethi
mohsin tahir sethi

Reputation: 59

/usr/bin/ruby2.3: bad interpreter: No such file or directory

I am running Ubuntu 16.04 and when I open the console and write rails s to start my rails server, following error appears:

bash: /usr/local/bin/rails: /usr/bin/ruby2.3: bad interpreter: No such file or directory but if I use command bash -l then use rails s every thing works fine.

why do I always need to use bash -lcommand to use rails s ? How can I save myself from the overhead of always writing bash -l?

Upvotes: 5

Views: 12081

Answers (2)

君主不是你
君主不是你

Reputation: 489

First location your ruby install:

which ruby

add path to env variables:

vi ~/.bashrc
export PATH=$PATH:/usr/local/ruby-2.6.5/bin

Next, location bundle which bundle

edit bundle first line

vi  /usr/local/bin/bundle

#!/usr/bin/ruby2.3
TO
/usr/local/ruby-2.6.5/bin/ruby

Upvotes: 4

Warren Young
Warren Young

Reputation: 42323

The answer to your title question is that you are attempting to use a distribution of Rails that was made for a different OS, where /usr/bin/ruby2.3 exists. While you may be able to hack that distribution into working on your OS, it is far simpler to use a version of Rails packaged for your OS specifically. Most Linux OSes have a version in their package repository already.

As for your second question (bash -l), you haven't provided enough info to answer it. However, it is highly likely that solving the title question in the way I suggest will solve this problem as well, since the basic problem must be some kind of user environment misconfiguration, which won't happen if you use the OS-provided version of Rails. Bottom line, you should never have to force a Bash login shell that way.

Upvotes: 1

Related Questions