graphman65 / linter-vhdl

Atom vhdl linter
https://atom.io/packages/linter-vhdl
MIT License
6 stars 2 forks source link

Need to set up environment variables #16

Open zerkman opened 3 years ago

zerkman commented 3 years ago

Hi,

TL;DR: In my environment, I cannot run ghdl without changing the LD_LIBRARY_PATH environment variable. There should be a way to change environment variables in linter-vhdl.

Long version: My OS is an up-to-date Debian testing (bullseye) amd64. Atom is installed using flatpak from the flathub repository. It is a kind of sandboxed environment which does not provide access to the main OS by default. Instead, Atom runs on a "runtime" environment, which is a standardized system with various utilities already pre-installed: git, gcc, clang, and others, but not ghdl. I can provide the environment access to the host’s /usr/bin directory (which becomes available as /var/run/host/usr/bin in the sandboxed environment), and ghdl becomes available as /var/run/host/usr/bin/ghdl. Unfornately, the ghdl binary is dependent from a libgnarl-9.so.1 library, which is not available in the sandboxed environment, and I have to change the LD_LIBRARY_PATH so dynamic linking finds the library in the correct place in the host’s filesystem. Here is a shell session in the sanboxed environment:

root@debian:~# flatpak run --filesystem=host-os:ro org.freedesktop.Sdk
[📦 org.freedesktop.Sdk ~]# /var/run/host/usr/bin/ghdl
/var/run/host/usr/bin/ghdl-mcode: error while loading shared libraries: libgnarl-9.so.1: cannot open shared object file: No such file or directory
[📦 org.freedesktop.Sdk ~]# LD_LIBRARY_PATH=/var/run/host/usr/lib/x86_64-linux-gnu /var/run/host/usr/bin/ghdl
/var/run/host/usr/bin/ghdl-mcode:error: missing command, try /var/run/host/usr/bin/ghdl-mcode --help
[📦 org.freedesktop.Sdk ~]# 

In the linter-vhdl settings, I already changed the path to ghdl accordingly. But I really need to be able to set that LD_LIBRARY_PATH value.

A better alternative would be that linter-vhdl detects it runs on a sandboxed Atom, issues warnings if it cannot access the host filesystem or has trouble with dynamic linking, and automatically sets itself up if everything is available.

Thanks a lot for reading me, and for your very good work on linter-vhdl.

graphman65 commented 3 years ago

Hi,

Sorry for the delay, I've just published a new version with a new config value called compileEnvVars. It can be used by providing some JSON formatted string (eg: { "LD_LIBRARY_PATH": "/usr/share" }).

I'll try to add this to README asap but feel free to use it and report if anything is not working for your usecase.

zerkman commented 3 years ago

Hi,

Thank you for taking the time for my problem.

I have updated to the new version, and now I can see the new environment field in the settings. So I have set the VHDL compiler path to /var/run/host/usr/bin/ghdl I have set the Compiler environment variables to LD_LIBRARY_PATH=/var/run/host/usr/lib/x86_64-linux-gnu

Somehow, after setting the correct values, errors are still not detected. No message appears in the Atom console either. It is just like linter-vhdl is doing nothing.

Is there any way to detect whether ghdl could not be found, or if it runs with errors ?