Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[question] What is the correct way of exposing PATH when packaging library type? #16313

Closed
1 task done
uilianries opened this issue May 21, 2024 · 2 comments
Closed
1 task done
Assignees

Comments

@uilianries
Copy link
Member

What is your question?

We have the PR conan-io/conan-center-index#24054 which simplifies the test package by only building a test application and running a packaged tool.

When trying to run the packaged tool, there is no PATH configured by VirtualRunEnv generator, resulting in failure when calling self.run(... , env='conanrun')

After talking with @RubenRBS , it's related to the package type of the recipe: library. The recipe packages not only libraries, but applications too.

The documentation is not clear about this situation, because VirtualRunEnv says:

Also automatically deduced from the self.cpp_info definition of the package to define PATH.
...
conanrunenv-release-x86_64.(bat|ps1|sh): This file contains the actual definition of environment variables like PATH, LD_LIBRARY_PATH, etc, and runenv_info of dependencies corresponding to the host context, and to the current installed configuration. If a repeated call is done with other settings, a different file will be created.

Reading this section I understand PATH would be available too.

As workaround, we need to force the PATH via the recipe, like:

def package_info(self):
    self.runenv_info.append_path("PATH", os.path.join(self.package_folder, "bin"))

Is there a better/correct way to manage this situation: Be able to call self.run("...", env='conanrun') without changing the PATH manually?

/cc @ErniGH

Have you read the CONTRIBUTING guide?

  • I've read the CONTRIBUTING guide
@memsharded memsharded self-assigned this May 21, 2024
@memsharded
Copy link
Member

Yes, you can't have both automatically, you cannot have a regular requires and run applications from it while being in the host context.

Note that adding it to the PATH while it is in the host context might confuse the users which might find the wrong executable when they pretended to use such executable as a tool_requires in the "build" context.

Another possibility would be that the self.requires(self.tested_reference_str, run=True) to force it to appear as a "run" requirement that will probably work.

@uilianries
Copy link
Member Author

@memsharded Thank you, now it's clear.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants