conan icon indicating copy to clipboard operation
conan copied to clipboard

Add Fish support for environments

Open AbrilRBS opened this issue 1 year ago • 7 comments

Changelog: Feature: Add Fish shell command support for environments Docs: https://github.com/conan-io/docs/pull/3690

Still need to check if the -g scope for the variable erasure is ok, and how activating both :powershell and :fish confs work

AbrilRBS avatar Jan 23 '24 12:01 AbrilRBS

Well, I'm officially converted to the cult of Fish now, so I'm interested as well.

I'll take a look with Ruben to push this PR again.

uilianries avatar Mar 22 '24 11:03 uilianries

To understand the current error when trying to use conanrun.sh with fish:

⋊> source conanrun.sh 
/private/tmp/foo/conanrunenv-release-armv8.sh (line 1): Unsupported use of '='. In fish, please use 'set script_folder "/private/tmp/foo"'.
script_folder="/private/tmp/foo"
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
from sourcing file /private/tmp/foo/conanrunenv-release-armv8.sh
	called on line 1 of file conanrun.sh
from sourcing file conanrun.sh
.: Error while reading file '/private/tmp/foo/conanrunenv-release-armv8.sh'

So, it's incompatible with Fish right now. Just to have an idea, pyenv generates both activate and activate.fish.

I'll check if we can do something compatible with both, because it's a really small script that we have.

uilianries avatar Apr 02 '24 15:04 uilianries

Add new test to validate consuming a tool requirement using Fish shell. It should be able to load the tool without errors.

uilianries avatar Apr 04 '24 13:04 uilianries

@memsharded Thank you for your early review. I just talked to @RubenRBS few minutes ago and found other cases to be testes using spaces and some alternatives for deactivation via memory function.

Most of these changes were made to track the creation of conanbuild.sh and how conan_run invokes with wrapper. I have to confess I spent few hours to understand the flow.

uilianries avatar Apr 12 '24 14:04 uilianries

I'm not sure about the logic that I added: In case a variable already exist, it will be prepend to that variable.

Pros: Preserves system variables and variables already configured by another Conan dependency.

Cons: If an user runs conanbuild.fish twice, all variables will be broken as they will be value duplicated.

I still need to fix some important points when manipulating paths, it's not working right now when needing to prepend.

uilianries avatar Apr 15 '24 19:04 uilianries

We still need to activate Fish in the CI, otherwise, we will not be able to validate it.

It works in my machine™:

pytest -vvv conans/test/functional/toolchains/env/test_virtualenv_fish.py                                                                                                                                                 18:34:59
============================================================================================================================= test session starts ==============================================================================================================================
platform darwin -- Python 3.10.4, pytest-7.4.4, pluggy-1.4.0 -- /Users/uilian/Development/conan/conan-io/venv/bin/python
cachedir: .pytest_cache
rootdir: /Users/uilian/Development/conan/conan-io
configfile: pytest.ini
plugins: xdist-3.5.0
collected 11 items                                                                                                                                                                                                                                                             

conans/test/functional/toolchains/env/test_virtualenv_fish.py::test_define_new_vars PASSED                                                                                                                                                                               [  9%]
conans/test/functional/toolchains/env/test_virtualenv_fish.py::test_prepend_path[/path/to/fake/folder] PASSED                                                                                                                                                            [ 18%]
conans/test/functional/toolchains/env/test_virtualenv_fish.py::test_prepend_path[/path/with space/to/folder] PASSED                                                                                                                                                      [ 27%]
conans/test/functional/toolchains/env/test_virtualenv_fish.py::test_transitive_tool_requires[Dulcinea del Toboso-True-True] PASSED                                                                                                                                       [ 36%]
conans/test/functional/toolchains/env/test_virtualenv_fish.py::test_transitive_tool_requires[Dulcinea del Toboso-True-False] PASSED                                                                                                                                      [ 45%]
conans/test/functional/toolchains/env/test_virtualenv_fish.py::test_transitive_tool_requires[Dulcinea del Toboso-False-True] PASSED                                                                                                                                      [ 54%]
conans/test/functional/toolchains/env/test_virtualenv_fish.py::test_transitive_tool_requires[Dulcinea del Toboso-False-False] PASSED                                                                                                                                     [ 63%]
conans/test/functional/toolchains/env/test_virtualenv_fish.py::test_transitive_tool_requires[Dulcinea-Del-Toboso-True-True] PASSED                                                                                                                                       [ 72%]
conans/test/functional/toolchains/env/test_virtualenv_fish.py::test_transitive_tool_requires[Dulcinea-Del-Toboso-True-False] PASSED                                                                                                                                      [ 81%]
conans/test/functional/toolchains/env/test_virtualenv_fish.py::test_transitive_tool_requires[Dulcinea-Del-Toboso-False-True] PASSED                                                                                                                                      [ 90%]
conans/test/functional/toolchains/env/test_virtualenv_fish.py::test_transitive_tool_requires[Dulcinea-Del-Toboso-False-False] PASSED                                                                                                                                     [100%]

uilianries avatar Apr 16 '24 16:04 uilianries

Fish is now installed and configured with tests. Time for review!

uilianries avatar Apr 22 '24 14:04 uilianries