To help us debug your issue please explain:
OS: Windows 7 Enterprise
Conan version: 1.15.1 (installed via pip)
Python: 3.7.2
We encountered a problem when launching virtual environment with activate.sh under Windows.
We launch it from Git bash:
"source activate.sh"
But the PATH seems not to be appended correctly (the slashes are wrongly set)
(PATH="C:\Users\uid95125\.conan\data\Tool1\2.0.0\conti_gen_dev1\stable\package\5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9\bin"${PATH+:$PATH})
When we try to launch our bash script in the virtual environment it cannot be found (due to the wrongly created PATH)
After we manually change the path (slashes) in "activate.sh" and activate again the virtual env ("source activate.sh"), the tool (bash script) can be called.
(PATH="/C/Users/uid95125/.conan/data/Tool1/2.0.0/conti_gen_dev1/stable/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/bin"${PATH+:$PATH})
Here is the detailed use case (under Windows):
[requires]
Tool1/2.0.0@conti_gen_dev1/stable
[generators]
virtualenv
conan install .OLD_PS1="$PS1"
export OLD_PS1
PS1="(conanenv) $PS1"
export PS1
PATH="C:\Users\uid95125\.conan\data\Tool1\2.0.0\conti_gen_dev1\stable\package\5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9\bin"${PATH+:$PATH}
export PATH
source activate.shsource first_sh.shOLD_PS1="$PS1"
export OLD_PS1
PS1="(conanenv) $PS1"
export PS1
PATH="/C/Users/uid95125/.conan/data/Tool1/2.0.0/conti_gen_dev1/stable/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/bin"${PATH+:$PATH}
export PATH
source first.shI have attached also the output when the virtual environment sets the path wrong and when it is set correctly:
RunNOK.txt
RunOK.txt
Can you help us with this? Are we doing the things wrong?
If someone has a tool which is a bash script how shall this be found?
Is this the expected behavior of activate.sh under Windows (or is a bug)?
Do you propose a workaround for our use case?
Hi @CristinaBa
I am checking this issue, and you are right, this is problematic behavior.
I guess you have something in the package like:
def package_info(self):
self.env_info.PATH=[self.package_folder]
Which adds itself to the path, so the script is later found there.
The main problem is that such self.package_folder is managed by the system (python interpreter) and it is OS dependent, paths in Windows are using backslash, so that is why that path gets all the way to the activate.sh script. The reason it hasn't been noticed yet might be that most people in Windows uses the .bat, not the .sh scripts.
A possible workaround is to force the slashes just once in the package, so it is not necessary to do it downstream every time:
def package_info(self):
self.env_info.PATH=[self.package_folder.replace("\\\\", "/")]
I am trying to think about other possibilities, but the truth is that the virtualenv generator is agnostic of variables, it doesn't know that such thing is a path, so it seems a bit tricky to change the path in the virtualenv generator.
Please let me know if the above makes the trick. Thanks!
Hello @memsharded
thanks for the reply.
Unfortunately the workaround you suggested is not the best option for us.
We were thinking as an option to develop a custom generator to solve our problem.
If you have any other ideas or workarounds please let us know.
Thanks!
I am exploring possibilities here: https://github.com/conan-io/conan/pull/5534 Note that this is not intended to be merged, only reviewed to check possible approaches.
The main problem here is that paths are given by the system. By default in Windows it uses backslash. That path is assigned to an env-var.
When the virtualenv files are generated, it is not possible to know what represents a path and what not. The PR just hardcode some possible env-var names, but that is a bit hacky.
Are you generating the activate scripts also in the git console? Maybe the generator could detect the "subsystem" and generate the paths with the correct slashes. I don't like it a lot... but we might consider it.
I've used activate.sh on both Linux & Windows since a very long time, but just recently noticed this same issue (cleared the cache, updated conan and did a clean build, so probably it changed a while back)...
Anything particular that has changed? AFAIK my packages (or at least the one causing issues) have not changed.