Ubuntu wrong interpreter: permission denied bundle install

Solved
Sawney -  
mamiemando Posted messages 33228 Registration date   Status Moderator Last intervention   -
Hello everyone,

I've just set up a dual boot Windows/Ubuntu on my machine to develop with Ruby on Rails.

First of all, I'm having a problem with the installation of
ruby
. I need version 2.6.5 (which I installed with
rbenv
), but when I run the command
rbenv global 2.6.5
,
ruby
doesn't change its version and remains on the default one:
2.7.0
. It still doesn't work, even with the command
rbenv local 2.6.5
..

Then, I received a new error message when I was running
bundle install
:

marie@travail:~$ bundle install
bash: /usr/local/bin/bundle : /home/marie/.rbenv/versions : bad interpreter: Permission denied


Indeed, I changed (because I saw it on a forum) the file
/usr/local/bin/bundle
:
I modified the first line to:
#!/home/marie/.rbenv/versions


Please note that I've changed all the permissions in the path and I really don't see where the problem comes from.
Even when I run
sudo bundle install
, it still returns Permission denied;

I'm really confused, I don't know what to do... I saw on another forum that the problem could be related to my partition, so I ran a
cat /etc/fstab
and now I'm completely lost....

Here's the content of
/etc/fstab
:

# /etc/fstab: static file system information. # # Use 'blkid' to print the universally unique identifier for a # device; this may be used with UUID= as a more robust way to name devices # that works even if disks are added and removed. See fstab(5). # # <file system> <mount point> <type> <options> <dump> <pass> # / was on /dev/nvme0n1p5 during installation UUID=5ab942be-c758-42c8-82a9-a6502c5e6404 / ext4 errors=remount-ro 0 1 # /boot/efi was on /dev/nvme0n1p1 during installation UUID=4CEB-EA65 /boot/efi vfat umask=0077 0 1 /swapfile none swap sw 0 0 

If you have any ideas or solutions, feel free to let me know..

Thanks in advance

2 answers

  1. mamiemando Posted messages 33228 Registration date   Status Moderator Last intervention   7 940
     
    Hello,

    Well, there are several things mixed up in your message, so let's try to untangle all that :-)

    To start, one should try to install software as much as possible via their package manager (in your case,
    apt
    ) or any software built on it (including the Ubuntu Software Center).

    To install
    rbenv
    :

    sudo apt update sudo apt upgrade sudo apt install rbenv


    To learn how to use a command, it's best to read its
    man
    page beforehand by typing in a terminal
    man rbenv
    (man pages are also available online, here is the man page for
    rbenv
    ).

    As indicated on this page,
    rbenv
    allows you to install and switch between different
    ruby
    interpreters. In your case, I assume you would need to run:

    rbenv init echo 'eval "$(rbenv init -)"' >> ~/.bashrc rbenv install 2.4.5 rbenv global 2.4.5 ruby -v


    Can you report back the results of these commands?

    Now let's look at some leads (in my opinion, dubious):

    /usr/local/bin/bundle

    I don't know what it is, but the path suggests that
    bundle
    (whatever it is) was not installed via
    apt
    , so it doesn't bode well (or there is a neater way to do it).

    If you believe you need this executable, you should install the correct package via
    apt
    . To find it, you can use
    apt-file
    :

    sudo apt install apt-file sudo apt-file update sudo apt-file search bundle | grep bin/bundle$


    On Debian, it is provided by the package
    ruby-bundler
    , so you would run:

    sudo apt install ruby-bundler


    #!/home/marie/.rbenv/versions

    A script whose first line starts with
    #!
    has a shebang, which indicates which interpreter (e.g.,
    bash
    ,
    python
    ,
    perl
    ,
    ruby
    ,
    php
    ...) to use to execute the script. This interpreter must be an executable, and is traditionally located in
    /usr/bin
    (
    /bin
    for bash). So for example, for a bash script, the shebang would be
    #!/usr/bin/bash
    .

    In this sense, the shebang you indicated in your file seems strange; it doesn't appear to point to an interpreter's path.

    The path
    /home/marie/.rbenv/versions
    probably exists, but since this file does not have execution rights (see
    ls -l /home/marie/.rbenv/versions
    ), it is normal that your shell responds with "Permission denied".

    Here are some tips and recommendations when you get a permission error.
    • Start by understanding what caused the error:
      • What are the rights associated with the affected file -
        ls -l
        ?
      • What is my current profile -
        whoami
        ?
      • Which groups does it belong to -
        groups
        ?
    • Never relax the rights associated with this file (these are usually well defined by default, and relaxing them can open a security hole) - so
      chmod
      and
      chown
      are generally a very bad approach.
    • Do not reflexively fall back on
      sudo
      , at least until you understand what you're doing: because as soon as you switch to administrator, a mistake could have dramatic consequences.


    /etc/fstab

    That's a bad lead someone gave you. Certainly,
    /etc/fstab
    can explain a permission issue, but here the problem comes from your attempt to execute something that is not an executable.

    This file defines how the directory tree
    /
    is fed from the various devices made available by your system (which includes hard drive partitions): for each device, its mount point (an empty folder) and its mount options (including possible read-only access with the
    ro
    option) are defined. Similarly, there are options regarding execution (namely, the
    exec
    and
    noexec
    options).

    In any case, your partitions are normally mounted with default options, so you have no reason to touch them.

    For more details, you can read
    man fstab
    .

    Good luck
    0
  2. Sawney.-
     
    Hello,

    I managed to solve all my problems. In fact, the dual boot I had installed on my computer had an issue. I reinstalled Ubuntu and all the permission-related problems were resolved.

    I had another problem with the rbenv command: I couldn't change the version of
    ruby
    .
    When I ran the command
    rbenv global 2.6.5
    and then
    ruby -v
    , the version of
    ruby
    didn't change.

    I found the solution on this forum: https://stackoverflow.com/questions/65817956/your-ruby-version-is-2-7-0-but-your-gemfile-specified-3-0-0

    Thank you for your quick response and your help, your explanations were really useful to me.
    0
    1. mamiemando Posted messages 33228 Registration date   Status Moderator Last intervention   7 940
       
      Glad to hear it :-) Thank you for your positive feedback and best of luck!
      0