Skip to content

Fix crash for updates to environment with empty strings#5350

Merged
dra27 merged 6 commits intoocaml:masterfrom
dra27:empty-envs
Jan 24, 2023
Merged

Fix crash for updates to environment with empty strings#5350
dra27 merged 6 commits intoocaml:masterfrom
dra27:empty-envs

Conversation

@dra27
Copy link
Copy Markdown
Member

@dra27 dra27 commented Nov 14, 2022

#4326 fixed the handling of FOO = "" in setenv/build-env, but for all the other operators, although opam can parse the environment file, it crashes. The root cause of the crash is that our path split functions return [] when passed an empty string (I think is a bad idea, but it comes from ocaml-re, and it's a bit pervasive - String.split_on_char in the stdlib I think has a more coherent approach).

The first commit fixes the crash. The second commit capitalises on the fact that opam has never supported FOO += "" correctly. The second commit causes opam to skip such updates entirely. This means, for example, that PATH += "" is ignored (if the package really intended adding the current directory to PATH, then PATH += "." already works today).

@rjbou rjbou added this to the 2.1.5 milestone Jan 6, 2023
@rjbou rjbou mentioned this pull request Jan 6, 2023
5 tasks
rjbou and others added 6 commits January 23, 2023 14:47
@dra27 dra27 merged commit 79affca into ocaml:master Jan 24, 2023
@dra27 dra27 deleted the empty-envs branch January 24, 2023 11:04
@rjbou rjbou mentioned this pull request Feb 15, 2023
kit-ty-kate pushed a commit to kit-ty-kate/opam that referenced this pull request Feb 17, 2023
Fix crash for updates to environment with empty strings
rjbou pushed a commit to kit-ty-kate/opam that referenced this pull request May 12, 2023
Fix crash for updates to environment with empty strings
@dra27 dra27 mentioned this pull request Jun 13, 2024
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

Successfully merging this pull request may close these issues.

2 participants