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

Using the += opetator in build-env to prepend an empty (but set) variable adds a trailing seperator #5925

Closed
gridbugs opened this issue Apr 18, 2024 · 1 comment · Fixed by #5935
Assignees
Milestone

Comments

@gridbugs
Copy link
Contributor

gridbugs commented Apr 18, 2024

This is contrary to the documentation here:

+= or := prepend. They differ when the variable is unset of empty, where := adds a trailing separator.

To reproduce, put the following in a file named foo.opam:

opam-version: "2.0"

build-env: [
 [ FOO = "" ]
 [ FOO += "foo" ]
]

install: [
 [ "bash" "-c" "echo FOO=$FOO >> %{lib}%/x" ]
]

Then run:

opam switch create .
opam install ./foo.opam
cat _opam/lib/x

The output will be be:

FOO=foo:

But according to the documentation the output should be:

FOO=foo

I'm on linux. Reproduced on both 2.1.5 and opam-2.2.0-beta2.

@dra27 dra27 self-assigned this Apr 24, 2024
dra27 added a commit to dra27/opam that referenced this issue Apr 25, 2024
NV_VARS6 and NV_VARS8 should be foo (no colons)
dra27 added a commit to dra27/opam that referenced this issue Apr 29, 2024
NV_VARS6 and NV_VARS8 should be foo (no colons)
@dra27
Copy link
Member

dra27 commented Apr 30, 2024

OK, I've been looking at this in more detail with the preparatory work in #5935. Cross-referencing a slew of other previous issues in this area to be sure we don't accidentally regress them (because the fixes predate the reftests infrastructure):

With that history paged in, I still think this issue is unequivocally a bug (i.e. the docs are correct and opam isn't adhering to them). It might be relevant to see whether OPAM 1.2.2 was doing this, in terms of assessing whether fixing this may cause a regression.

dra27 added a commit to dra27/opam that referenced this issue May 2, 2024
NV_VARS5925_1 thru _4 should all be foo (i.e. without no colon)
dra27 added a commit to dra27/opam that referenced this issue May 2, 2024
Ensure that if opam has internally synthesised an empty environment
variable, then adding to it doesn't create a stray colon.
@dra27 dra27 linked a pull request May 2, 2024 that will close this issue
2 tasks
rjbou pushed a commit to rjbou/opam that referenced this issue May 10, 2024
NV_VARS5925_1 thru _4 should all be foo (i.e. without no colon)
rjbou pushed a commit to rjbou/opam that referenced this issue May 10, 2024
Ensure that if opam has internally synthesised an empty environment
variable, then adding to it doesn't create a stray colon.
rjbou pushed a commit to rjbou/opam that referenced this issue May 10, 2024
NV_VARS5925_1 thru _4 should all be foo (i.e. without no colon)
rjbou pushed a commit to rjbou/opam that referenced this issue May 10, 2024
Ensure that if opam has internally synthesised an empty environment
variable, then adding to it doesn't create a stray colon.
rjbou pushed a commit to rjbou/opam that referenced this issue May 10, 2024
NV_VARS5925_1 thru _4 should all be foo (i.e. without no colon)
rjbou pushed a commit to rjbou/opam that referenced this issue May 10, 2024
Ensure that if opam has internally synthesised an empty environment
variable, then adding to it doesn't create a stray colon.
rjbou pushed a commit to rjbou/opam that referenced this issue May 10, 2024
NV_VARS5925_1 thru _4 should all be foo (i.e. without no colon)
rjbou pushed a commit to rjbou/opam that referenced this issue May 10, 2024
Ensure that if opam has internally synthesised an empty environment
variable, then adding to it doesn't create a stray colon.
rjbou pushed a commit to rjbou/opam that referenced this issue May 10, 2024
NV_VARS5925_1 thru _4 should all be foo (i.e. without no colon)
rjbou pushed a commit to rjbou/opam that referenced this issue May 10, 2024
Ensure that if opam has internally synthesised an empty environment
variable, then adding to it doesn't create a stray colon.
dra27 added a commit to dra27/opam that referenced this issue May 14, 2024
NV_VARS5925_1 thru _4 should all be foo (i.e. without no colon)
dra27 added a commit to dra27/opam that referenced this issue May 14, 2024
Ensure that if opam has internally synthesised an empty environment
variable, then adding to it doesn't create a stray colon.
dra27 added a commit to dra27/opam that referenced this issue May 14, 2024
Ensure that if opam has internally synthesised an empty environment
variable, then adding to it doesn't create a stray colon.
dra27 added a commit to dra27/opam that referenced this issue May 14, 2024
Ensure that if opam has internally synthesised an empty environment
variable, then adding to it doesn't create a stray colon.
dra27 added a commit to dra27/opam that referenced this issue May 15, 2024
NV_VARS5925_1 thru _4 should all be foo (i.e. without no colon)
dra27 added a commit to dra27/opam that referenced this issue May 15, 2024
Ensure that if opam has internally synthesised an empty environment
variable, then adding to it doesn't create a stray colon.
@kit-ty-kate kit-ty-kate added this to the 2.2.0~beta3 milestone May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants