gazebosim / gazebo-classic

Gazebo classic. For the latest version, see https://github.com/gazebosim/gz-sim
http://classic.gazebosim.org/
Other
1.21k stars 484 forks source link

Setting GAZEBO_PLUGIN_PATH overrides the compile-time default #1949

Open osrf-migration opened 8 years ago

osrf-migration commented 8 years ago

Original report (archived issue) by Louise Poubel (Bitbucket: chapulina, GitHub: chapulina).


By default, plugins shipped with Gazebo work without the need to set extra environment variables. For example, insert Submarine (buoyant) from the insert tab and it floats.

But when you want to use custom plugins and set the GAZEBO_PLUGIN_PATH environment variable, for example:

export GAZEBO_PLUGIN_PATH=`pwd`:$GAZEBO_PLUGIN_PATH

Then the default plugins stop working. Trying to insert the submarine now prints this message:

[Err] [Plugin.hh:165] Failed to load plugin libBuoyancyPlugin.so: libBuoyancyPlugin.so: cannot open shared object file: No such file or directory

This is because, if GAZEBO_PLUGIN_PATH is set, we ignore the compile-time path, in SystemPaths::UpdatePluginPaths()

osrf-migration commented 8 years ago

Original comment by Steve Peters (Bitbucket: Steven Peters, GitHub: scpeters).


I think one is supposed to source the gazebo setup.sh file before modifying the GAZEBO_ variables. Maybe not the best approach

osrf-migration commented 8 years ago

Original comment by Silvio Traversaro (Bitbucket: traversaro).


If the setup.sh needs to be sourced before modifying the Gazebo environmental variables (as mentioned in the components tutorial ) it would be nice to mention this in the plugins hello world tutorial that probably introduced the GAZEBO_PLUGIN_PATH variable to most developers of Gazebo plugins.

osrf-migration commented 8 years ago

Original comment by Louise Poubel (Bitbucket: chapulina, GitHub: chapulina).


I had no idea it would be possible to do it by sourcing the setup file first. I agree that we should mention this in some tutorial.

Is there a downside to making it work without the setup file though? I guess there are cases when the user wants to override the default path?

osrf-migration commented 8 years ago

Original comment by Nate Koenig (Bitbucket: Nathan Koenig).


chapulina commented 3 years ago

As a reference, on Ignition we don't let the environment variables prevent the official resources from being found / loaded. So setting IGN_GAZEBO_RESOURCE_PATH won't break any core usage, because we always lookup the install paths, and there's no need to source a setup file.

My suggestion to resolve this issue would be to do the same here. That is, always prepend the env var to the compile time paths, instead of overriding them. That would be done here:

https://github.com/osrf/gazebo/blob/17c693050d43c8348e2e64a149ac4f3e6bd93daa/gazebo/common/SystemPaths.cc#L199-L208