Forum: Ruby problem with ruby and visual studio code

C4715313bdcd8fb570af712b2fd5b3a9?d=identicon&s=25 Rodrigo Batista (omag0)
on 2016-08-30 03:37
Hello folks. I got a problem with Visual Studio Code and i tried
everything and i cant resolve.

I use Centos 7, instaled ruby, rails, some gems (gem install
ruby-debug-ide, gem install debase) and visual studio code.
When i try debug show to me this error:
"/opt/rh/rh-ruby23/root/usr/bin/ruby: error while loading shared
libraries: libruby.so.2.3: cannot open shared object file: No such file
or directory"

How i fix this?
thx for help.

ps: sorry for my bad english.
0fa73332c8e4a3b06ea439fd3f034322?d=identicon&s=25 Ronald Fischer (rovf)
on 2016-08-30 06:19
Is the directory, where libruby.so.2.3 is found, in your
LD_LIBRARY_PATH?
C4715313bdcd8fb570af712b2fd5b3a9?d=identicon&s=25 Rodrigo Batista (omag0)
on 2016-08-30 13:03
my libruby.so.2.3 is in: /opt/rh/rh-ruby23/root/usr/lib64

my $PATH:
/opt/rh/rh-ruby23/root/usr/local/bin:/opt/rh/rh-ruby23/root/usr/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:/home/rodrigo/.local/bin:/home/rodrigo/bin

and my ruby extension vscode config.
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Debug Local File",
            "type": "Ruby",
            "request": "launch",
            "cwd": "${workspaceRoot}",
            "program": "${workspaceRoot}/main.rb"
        },
        {
            "name": "Listen for rdebug-ide",
            "type": "Ruby",
            "request": "attach",
            "cwd": "${workspaceRoot}",
            "remoteHost": "localhost",
            "remotePort": "3000",
            "remoteWorkspaceRoot": "${workspaceRoot}"
        },
        {
            "name": "Rails server",
            "type": "Ruby",
            "request": "launch",
            "cwd": "${workspaceRoot}",
            "program": "${workspaceRoot}/bin/rails",
            "args": [
                "server"
            ]
        },
        {
            "name": "RSpec - all",
            "type": "Ruby",
            "request": "launch",
            "cwd": "${workspaceRoot}",
            "program": "${workspaceRoot}/bin/rspec",
            "args": [
                "-I",
                "${workspaceRoot}"
            ]
        },
        {
            "name": "RSpec - active spec file only",
            "type": "Ruby",
            "request": "launch",
            "cwd": "${workspaceRoot}",
            "program": "${workspaceRoot}/bin/rspec",
            "args": [
                "-I",
                "${workspaceRoot}",
                "${file}"
            ]
        },
        {
            "name": "Cucumber",
            "type": "Ruby",
            "request": "launch",
            "cwd": "${workspaceRoot}",
            "program": "${workspaceRoot}/bin/cucumber"
        }
    ]
}


when i try, on terminal, run rails server, show to me the same error
(/opt/rh/rh-ruby23/root/usr/bin/ruby: error while loading shared
libraries: libruby.so.2.3: cannot open shared object file: No such file
or directory). So i do scl enable rh-ruby23 bash, and run again rails
server, and work.
I need to try something like that on vscode?
0fa73332c8e4a3b06ea439fd3f034322?d=identicon&s=25 Ronald Fischer (rovf)
on 2016-08-30 15:24
I said *LD_LIBRARY_PATH*, not *PATH*.
C4715313bdcd8fb570af712b2fd5b3a9?d=identicon&s=25 Rodrigo Batista (omag0)
on 2016-08-30 19:09
Now im lost. Im new on linux and i dont know how to do this.
Can you exlplain?

thx for help!
0fa73332c8e4a3b06ea439fd3f034322?d=identicon&s=25 Ronald Fischer (rovf)
on 2016-08-31 11:05
When a program needs to load a shared library, it needs to load it. Like
PATH specifies the directories, where executables are found, the
environment variable LD_LIBRARY_PATH specifies, in which directories to
look for shared libraries.
4828d528e2e46f7c8160c336eb332836?d=identicon&s=25 Robert Heiler (shevegen)
on 2016-09-03 03:45
You need to add the directory where libruby.so.2.3 is.

Edit /etc/ld.conf.so and add the path into a new line

Then run "ldconfig".

Then try to run ruby again.

LD_LIBRARY_PATH is another way:

    export LD_LIBRARY_PATH=/opt/rh/rh-ruby23/root/usr/lib64/

Remember that the typical hierarchies are /usr/ and / for "critical"
components that are required for boot (hence with that prefix, you will
populate /bin and /lib e. g. glibc is in the latter); /opt is
non-standard and optional.

I do not know why centos uses these paths, it sounds very wrong. I
assume you installed ruby from some centos repository.

If all fails, try to get a ruby in another way, from source or from rvm
or rbenv etc...

Latest ruby is:

  ftp://ftp.ruby-lang.org/pub/ruby/2.3/ruby-2.3.1.tar.xz

For LD_LIBRARY_PATH variable see:

http://stackoverflow.com/questions/13428910/how-to...
0fa73332c8e4a3b06ea439fd3f034322?d=identicon&s=25 Ronald Fischer (rovf)
on 2016-09-03 08:36
> export LD_LIBRARY_PATH=/opt/rh/rh-ruby23/root/usr/lib64/

Be careful! This is only correct, if LD_LIBRARY_PATH has not been set
before. After all, the application might depend on other shared libs,
and your assignment would remove them from the path.

I usually do it like this (example for bash/zsh):

    newlib=/opt/rh/rh-ruby23/root/usr/lib64
    if [[ -z $LD_LIBRARY_PATH ]]
    then
      export LD_LIBRARY_PATH=$newlib
    else
      LD_LIBRARY_PATH=$newlib:$LD_LIBRARY_PATH
    fi
    unset newlib
C4715313bdcd8fb570af712b2fd5b3a9?d=identicon&s=25 Rodrigo Batista (omag0)
on 2016-09-03 13:48
Hello guys. I also tryed intellij and when i import ruby sdk, show to me
the
same error: /opt/rh/rh-ruby23/root/usr/bin/ruby: error while loading
shared
libraries: libruby.so.2.3: cannot open shared object file: No such file
or directory.


So... i searched for libruby.so and found on /opt/rh/ruby23/root/lib64/
libruby.so
libruby.so.2.3
libruby.so.2.3.0

and i did

sudo ln -s /opt/rh/ruby23/root/lib64/libruby.so /usr/lib64
sudo ln -s /opt/rh/ruby23/root/lib64/libruby.so.2.3 /usr/lib64
sudo ln -s /opt/rh/ruby23/root/lib64/libruby.so.2.3.0 /usr/lib64

so works like a charm.

Thank's for all help.
Cheers.

ps
Robert Heiler - Centos repo, has a ruby 1.9 (or something like that), so
i installed for rh repo (a third repo for centos). And go to /opt/rh.
But after a few days, I'm beginning to understand Linux.
ps2 - sorry for my bad english.


Rodrigo.
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.