Author Topic: Environment variables  (Read 4738 times)

Offline markos

  • Single posting newcomer
  • *
  • Posts: 4
Environment variables
« on: December 07, 2012, 11:22:49 pm »
Hello, everyone,

I am using the EnvVars plugin to try to set the PATH enviroment variable under Ubuntu, using Code::Blocks svn 8150.

Under the 'Environment variables' tab on 'Environment settings', I add the variable 'PATH' with the value 'test:$PATH'. In order to check it, I added a pre-build step in my project with the command 'echo $PATH'. When I compile my program, under the 'Build log' tab, I see "/usr/bin:/usr:test:/usr/local/sbin/...(other bin paths)".

I see it was set kind of correctly, but the paths '/usr/bin' and '/usr' were prepended to my options. Is there a way to change this behavior, I mean, not to prepend these paths?

Thanks,
Markos

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: Environment variables
« Reply #1 on: December 08, 2012, 12:13:23 am »
What is the master path of your active compiler?  It, and master/bin, are (likely) added to the path by the Compiler plugin so that the compiler executables can be found.

Offline markos

  • Single posting newcomer
  • *
  • Posts: 4
Re: Environment variables
« Reply #2 on: December 08, 2012, 12:44:10 am »
That's it!

My compiler path is in /usr. I did a little test, changing it from /usr to /usr/bin, and the paths changed to '/usr/bin' and '/usr/bin/bin'.

Can I append these paths to the PATH environment variable, instead of prepend them?

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Environment variables
« Reply #3 on: December 08, 2012, 01:37:10 am »
That's it!

My compiler path is in /usr. I did a little test, changing it from /usr to /usr/bin, and the paths changed to '/usr/bin' and '/usr/bin/bin'.

Can I append these paths to the PATH environment variable, instead of prepend them?
No (at least not at the moment).
It's hardcoded this way, to make sure the correct compiler is used.
It would possibly work, if it would be possible to ensure EnvVar-plugin sets the path later than the compiler-plugin does.

Offline markos

  • Single posting newcomer
  • *
  • Posts: 4
Re: Environment variables
« Reply #4 on: December 08, 2012, 02:20:40 am »
Ok.

Actually, that's what I am trying to do, to change the compiler from the system compiler to another version that I've just built.

Thank you very much!

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Environment variables
« Reply #5 on: December 08, 2012, 04:36:40 pm »
It would possibly work, if it would be possible to ensure EnvVar-plugin sets the path later than the compiler-plugin does.
As the envvar exposes its function to scripting, a pre-build step might work, too.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline markos

  • Single posting newcomer
  • *
  • Posts: 4
Re: Environment variables
« Reply #6 on: December 08, 2012, 05:23:58 pm »
I just tried that, it didn't work.

As a pre-build step, I did 'export TEST=test:${PATH}' and 'export'. The variable 'TEST' did not appear.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Environment variables
« Reply #7 on: December 09, 2012, 10:00:24 pm »
I just tried that, it didn't work.

As a pre-build step, I did 'export TEST=test:${PATH}' and 'export'. The variable 'TEST' did not appear.
I am not sure if you really tried what I meant, but just to make sure: I didn't mean a "export" statement, but calling a method exposed to scripting from the envvars plugin.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ