unexpected error cannot intersect: @1.6.4 && @1.5.4
Getting the following error in a random fashion as i move through terraform codebases
Error
$ terraform fmt -recursive
× unexpected error cannot intersect: @1.6.4 && @1.5.4
│ Error: cannot intersect: @1.6.4 && @1.5.4
│ at Module.intersect (https://deno.land/x/[email protected]/src/utils/semver.ts:382:30)
│ at condense (https://deno.land/x/[email protected]/src/plumbing/hydrate.ts:78:33)
│ at hydrate (https://deno.land/x/[email protected]/src/plumbing/hydrate.ts:13:15)
│ at file:///Users/builder/actions-runner/_work/pkgx/pkgx/src/prefab/install.ts:10:60
│ at failsafe (file:///Users/builder/actions-runner/_work/pkgx/pkgx/src/prefab/failsafe.ts:5:18)
│ at default (file:///Users/builder/actions-runner/_work/pkgx/pkgx/src/prefab/install.ts:10:47)
│ at eventLoopTick (ext:core/01_core.js:178:11)
│ at async default (file:///Users/builder/actions-runner/_work/pkgx/pkgx/src/modes/x.ts:30:18)
│ at async default (file:///Users/builder/actions-runner/_work/pkgx/pkgx/src/app.ts:48:11)
│ at async file:///Users/builder/actions-runner/_work/pkgx/pkgx/entrypoint.ts:59:3
╰─➤ https://github.com/pkgxdev/pkgx/issues/new
Workaround
Do dev off and then run dev
the only package.yml I see that mentions 1.5.4 is github.com/moretension/duti; none mention 1.6.4 that i can find. what is in your pkgx.yml or .terraform-version file?
likely this is a case of trying to get multiple different terraforms into the same env. iirc, there's a very subtle bug where moving from one dev env to another doesn't always work cleanly, so that is likely what you're hitting.
I am using only the .terraform-version file. The content of that would vary from one project folder to another (example below) and i keep switching between projects all through the day.
Project A
$ cat .terraform-version
1.6.4
Project B
$ cat .terraform-version
1.5.4
Project C
$ cat .terraform-version
0.13.7
so, I think this is the changing from one dev env to the other issue. i can think of two workarounds:
-
dev off; dev<- should reset everything -
cd ~; cd new/folder<- should do likewise
Any ideas to fix this at a code level ? I can try contributing a PR for this
Most likely the chdir hook in the shell needs to unload-then-load, but that could cause overhead, as well as deps changing in rare instances.
basically this code needs to know if it's going from one dev-env to another, rather than within a single dev-env. your test case looks something like this:
mkdir -p a/b a/c
echo -e "dependencies:\n llvm.org: ^15" >a/pkgx.yml
echo -e "dependencies:\n llvm.org: ^16" >a/b/pkgx.yml
cd a
dev
test "$(clang --version)" | grep "version 15"
cd b
test "$(clang --version)" | grep "version 16"
cd c
test "$(clang --version)" | grep "version 15"
cd b
test "$(clang --version)" | grep "version 16"
cd ..
test "$(clang --version)" | grep "version 15"
cd c
test "$(clang --version)" | grep "version 15"
i think.
I hit this too today, I would think it's related, but otherwise I'll open another issue. Tried to run pkgx psql in a folder with some packages already, and got:
$ env +psql
× unexpected error cannot intersect: ^71 && ^73
│ Error: cannot intersect: ^71 && ^73
│ at Module.intersect (https://deno.land/x/[email protected]/src/utils/semver.ts:384:30)
│ at hydrate (https://deno.land/x/[email protected]/src/plumbing/hydrate.ts:51:48)
│ at eventLoopTick (ext:core/01_core.js:181:11)
│ at async failsafe (file:///Users/runner/work/pkgx/pkgx/src/prefab/failsafe.ts:5:12)
│ at async default (file:///Users/runner/work/pkgx/pkgx/src/prefab/install.ts:10:41)
│ at async default (file:///Users/runner/work/pkgx/pkgx/src/modes/internal.use.ts:16:20)
│ at async default (file:///Users/runner/work/pkgx/pkgx/src/app.ts:65:20)
│ at async file:///Users/runner/work/pkgx/pkgx/entrypoint.ts:59:3
╰─➤ https://github.com/pkgxdev/pkgx/issues/new
Output of env:
PKGX_POWDER=nodejs.org^18 git-scm.org pkgx.sh
PKGX_PKGENV=curl.se/ca-certs=2023.8.22 gnome.org/libxml2=2.11.4 tukaani.org/xz=5.4.5 unicode.org=71.1.0 openssl.org=1.1.1w zlib.net=1.3.0 gnu.org/gettext=0.21.1 curl.se=8.3.0 perl.org=5.38.0 libexpat.github.io=2.5.0 nodejs.org=18.18.0 npmjs.com=9.9.0 git-scm.org=2.42.0 pkgx.sh=1.1.4
pkgx.yaml:
dependencies:
nodejs.org: 18
npmjs.com: 9
As i am getting this error very frequently, as a workaround i have added the following line to my ~/.zshrc which makes the problem disappear
dev off && dev
Sorry for this everyone. I’m actively figuring out solutions now.
K so this particular problem is in the dev shellcode. The unicode.org issue (^71 && ^73) is separate
How do I reproduce this?
I created two directories added .terraform-version files with 1.6.4 and 1.5.4 in. Then dev in each then cd ../other and don’t get any issues.
I've updated to the latest version, and I can't reproduce it anymore. In my case, I think it was caused by a pkgx.yaml with node 18 and {"engines": {"node": ">=20.0.0 < 21.0.0"}} in package.json.
When I try to dev in that directory, I get × invalid constraint for nodejs.org: undefined. And then when I try to dev off I get cmd not found: _pkgx_dev_off. Maybe it's all unrelated.
reproduce-pkgx $ pkgx --version
pkgx 1.1.5
The unicode issue is fixed in pkgx 1.1.6. The terraform one I cannot reproduce. @jakobvase yes asking for both node 18 and 20 would be a conflict, the other issues are separate bugs we should fix. I believe the constraint you specified is not supported by our semver range parser and the dev off error is just bad: it should say “no dev env” probs.
@mxcl I found the reason for my issue :-)
It was due to a terraform binary present in the path (~/.local/bin/terraform) installed using pkgx install [email protected] command conflicting with version specified in the .terraform-version file of the project
Prerequisites
- Ensure to have an iterm2 setup where you have enabled "Reuse previous session's directory" (screenshot below)
Steps for simulation
- Install terraform using
pkgx install [email protected] - Create a terraform project
mkdir -p terraform-repo && echo "1.6.4" > terraform-repo/.terraform-version -
cd terraform-repo -
dev - Run
terraform version- This will print out the right version (1.6.4) in the console without any errors - Press "Cmd + D" to create a tab pane which will initialize with the same current working directory and type
terraform version(screenshot below)
Having a terraform binary in PATH will not cause this issue.
A conflict is only possible if an existing pkg-env is present when trying to change that env. That environment is controlled by the PKGX_PKGENV environment variable and not by the presence of other programs in the PATH.
Is it possible that iTerm2 is preserving PKGX_PKGENV between sessions? Is it possible that you have a .terraform-version file in a higher directory that has also been enabled by typing dev?