Problem with ruby and visual studio code

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.

Is the directory, where libruby.so.2.3 is found, in your
LD_LIBRARY_PATH?

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?

I said LD_LIBRARY_PATH, not PATH.

Now im lost. Im new on linux and i dont know how to do this.
Can you exlplain?

thx for help!

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.

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 H. - 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.

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-set-the-environmental-variable-ld-library-path-in-linux

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs