1

I am trying to execute a source command from package info it is building but while trying to install it I am getting the following error.

sh: 1: source: not found
ERROR: package_name/7.0@repo/stable: Error in package_info() method, line 23
    self.run("source "+self.package_folder+"/pkgsdp-env.sh")
    ConanException: Error 32512 while executing source /home/tusharecmc/.conan/data/pkg/7.0/repo/stable/package/4db1be536558d833e52e862fd84d64d75c2b3656/pkgsdp-env.sh

My conanfile.py is as follow

from conans import ConanFile, tools


class pkgConan(ConanFile):
    name = "qnx"
    version = "7.0"
    settings = {"os":["Linux"],
                "arch":["x86_64"]
               }
    description = "Package for qnx os 7.0"
    url = "None"
    license = "None"
    author = "None"
    topics = ["pkg","os"]

    def package(self):
        self.copy("*")
        self.copy("pkgsdp-env.sh", src="./pkg700/")

    def package_info(self):
        self.cpp_info.libs = tools.collect_libs(self)
        self.env_info.path.append(self.package_folder+"/pkg700")
        self.run("source "+self.package_folder+"/pkgsdp-env.sh")
tushar_ecmc
  • 186
  • 2
  • 21

1 Answers1

1

I've created Conan package for a long time and it's the first time I see someone trying to run source in a recipe. Your command will not work, because your system is using /bin/dash, that does not support the command source.

I would say to change the permission and run it directly:

qnxsdpenv = os.path.join(self.package_folder, "qnxsdp-env.sh")
permission = stat.S_IMODE(os.lstat(qnxsdpenv).st_mode)
os.chmod(qnxsdpenv, (permission | stat.S_IEXEC))
self.run(qnxsdpenv)

But if qnxsdp-env.sh only set a few env vars, I would to set them by self.env_info instead, much cleaner and readable.

uilianries
  • 3,363
  • 15
  • 28
  • I am running virtualrunenv as generator. I have tried your both approaches,trying to source is giving the same error as before after doing the permission changes, so I tried setting self.env_info.VAR=Value but in virtual environment, echoing $VAR is showing empty. – tushar_ecmc Feb 07 '19 at 12:30
  • 1
    If you set the variable by env_info, you will need to use https://docs.conan.io/en/latest/reference/build_helpers/run_environment.html in your package target. Indeed env_info will not change your environment variables directly, otherwise it could mess your system. – uilianries Feb 07 '19 at 13:14