alire
alire copied to clipboard
Example not always working
Dear Alire Developers,
alr help printenv
yields
SUMMARY
Print the build environment variables
USAGE
alr printenv [options]
OPTIONS
--details Print details about the environment variables and their origin
--unix Use a UNIX shell format for the export (default)
--powershell Use a Windows PowerShell format for the export
--wincmd Use a Windows CMD shell format for the export
GLOBAL OPTIONS
-c (--config=ARG) Override configuration folder location
-f (--force) Keep going after a recoverable troublesome situation
-h (--help) Display general or command-specific help
-n (--non-interactive) Assume default answers for all user prompts
--no-color Disables colors in output
--no-tty Disables control characters in output
--prefer-oldest Prefer oldest versions instead of newest when resolving dependencies
-q Limit output to errors
-v Be more verbose (use twice for extra detail)
-d (--debug[]) Enable debug-specific log messages
DESCRIPTION
Print the environment variables used to build the crate. This command can be
used to setup a build environment, for instance before starting an IDE.
Examples:
- eval $(alr printenv --unix)
- alr printenv --powershell | Invoke-Expression
Although the last example is really helpful. It doesn't always work flawless
PS C:\path\to\Renaissance-Ada\src\tools\Code_Reviewer> alr printenv --powershell | Invoke-Expression
Note: : The term 'Note:' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ Note: Synchronizing workspace...
+ ~~~~~
+ CategoryInfo : ObjectNotFound: (Note::String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Dependencies : The term 'Dependencies' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ Dependencies automatically updated as follows:
+ ~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Dependencies:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Invoke-Expression : Cannot bind argument to parameter 'Command' because it is an empty string.
At line:1 char:30
+ alr printenv --powershell | Invoke-Expression
+ ~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:PSObject) [Invoke-Expression], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,Microsoft.PowerShell.Commands.InvokeExpressionCommand
warn: Generating possibly incomplete environment because of missing dependencies
New : The term 'New' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:4
+ New solution is incomplete.
+ ~~~
+ CategoryInfo : ObjectNotFound: (New:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Invoke-Expression : At line:1 char:5
+ +i gnat 11.2.4 (new,installed,gnat_native,indirect)
+ ~
Missing expression after unary operator '+'.
At line:1 char:5
+ +i gnat 11.2.4 (new,installed,gnat_native,indirect)
+ ~
Unexpected token 'i' in expression or statement.
At line:1 char:35
+ +i gnat 11.2.4 (new,installed,gnat_native,indirect)
+ ~
Missing argument in parameter list.
At line:1 char:30
+ alr printenv --powershell | Invoke-Expression
+ ~~~~~~~~~~~~~~~~~
+ CategoryInfo : ParserError: (:) [Invoke-Expression], ParseException
+ FullyQualifiedErrorId : MissingExpressionAfterOperator,Microsoft.PowerShell.Commands.InvokeExpressionCommand
This happens when alire is executed for the first time on a project / directory and other output to report progress is also provided.
Hopes this helps to make alire even better!
Pierre
It took me a time to make the wincmd equivalent of the powershell example. Maybe you can return it as part of the help text (or put it somewhere in the documentation) to help others:
for /F "usebackq delims=" %x in (`alr printenv --wincmd`) DO %x
Also this trick has the same limitations as I described earlier in this issue!
Thanks for the detailed report and research! We took some measures to make some warnings that can happen during alr printenv
go to stderr, but these ones escaped. It's probably too fragile to try to achieve this anyway; maybe we can add to the help that the safe way to invoke printenv is with -q
, or force it ourselves.
Hello @pjljvandelaar
Looks like alr printenv --powershell | Invoke-Expression
didn't work because Alire is outputting more message.
I would recommend running alr printenv --powershell
first to see if there anything to update on the Alire side.
And then do alr printenv --powershell | Invoke-Expression
@Fabien-Chouteau You describe a workaround that is similar to what I am currently using. First alr build
to make sure everything is fine. And only then use alr printenv
.
My workaround might indeed be slower, since building does problably more than just printing the environment values.
maybe we can add to the help that the safe way to invoke printenv is with
-q
, or force it ourselves.
Even with -q, some additional lines are present:
$ alr -q printenv
checking build system type... x86_64-apple-darwin21.5.0
checking host system type... x86_64-apple-darwin21.5.0
checking target system type... x86_64-apple-darwin21.5.0
checking whether gnat can build shared libs... yes
checking for a BSD-compatible install... /usr/bin/install -c
checking whether ln -s works... yes
configure: creating ./config.status
config.status: creating xmlada_shared.gpr
config.status: creating Makefile
config.status: creating tests/dom/default.gpr
export ALIRE="True"
...
Thus I use: % eval $(alr -q printenv --unix|grep export)
I just encountered the same problem on linux. What do you think about omitting all messages except the environment when using --unix
, --wincmd
or --powershell
as these are likely used in an environment that tries to parse the output and therefor breaks if anything other than environment declarations are printed?
If you have some minimal example that produces output to stdout after the fix in #1327 and with -q
that would be very useful.
@Blady-Com, is that output caused by some post-fetch
action or the like?
I tried to build a version after #1327 but I'm always running into the following problem:
clic-config-info.ads:1:20: error: file "toml.ads" not found
clic-config-info.ads:1:20: error: "CLIC.CONFIG.INFO (body)" depends on "CLIC.CONFIG.INFO (spec)"
clic-config-info.ads:1:20: error: "CLIC.CONFIG.INFO (spec)" depends on "CLIC.CONFIG (spec)"
clic-config-info.ads:1:20: error: "CLIC.CONFIG (spec)" depends on "TOML (spec)"
clic-config-load.adb:2:06: error: file "toml-file_io.ads" not found
clic-config-load.ads:3:20: error: file "toml.ads" not found
clic-config-load.ads:3:20: error: "CLIC.CONFIG.LOAD (body)" depends on "CLIC.CONFIG.LOAD (spec)"
clic-config-load.ads:3:20: error: "CLIC.CONFIG.LOAD (spec)" depends on "CLIC.CONFIG (spec)"
clic-config-load.ads:3:20: error: "CLIC.CONFIG (spec)" depends on "TOML (spec)"
Steps to reproduce:
$ git clone https://github.com/alire-project/alire.git
$ git submodule update --init --recursive
$ alr build
$ alr version
APPLICATION
alr version: 1.2.2
libalire version: 1.2.2
compilation date: 2023-01-12 20:53:49
compiler version: Community 2021 (20210519-103)
CONFIGURATION
config folder: /home/.../.config/alire
force flag: FALSE
non-interactive flag: FALSE
community index branch: stable-1.2.1
compatible index versions: ^1.1 & <=1.2.1
indexes folder: /home/.../.config/alire/indexes
indexes metadata: OK
index #1: (community) git+https://github.com/alire-project/alire-index#stable-1.2.1
toolchain assistant: disabled
tool #1 gnat: gnat_native=12.2.1
tool #2 gprbuild: gprbuild=22.0.1
WORKSPACE
root status: VALID
root release: alr=1.3.0-dev
root load error: none
root folder: /tmp/alire
current folder: /tmp/alire
SYSTEM
distribution: UBUNTU
host-arch: X86_64
os: LINUX
target: NATIVE
toolchain: USER
word-size: BITS_64
I tried to build a version after #1327 but I'm always running into the following problem:
Let's try to stay on topic, but see here: https://github.com/alire-project/alire/issues/1326
I tried alr -q printenv
with an alire built from 0a19027cd31b1c999bf544c9285a7def2aa308ad and it didn't produce any unwanted output for me, even if it was downloading dependencies and setting up the toolchain. So at least for me it seems the problem is fixed in that version.
@Blady-Com, is that output caused by some
post-fetch
action or the like?
Yes that's right, try for instance templates_parser crate.
Alright, I can reproduce with templates_parser
. That's definitely something concrete to fix.