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

unexpected error cannot intersect: @1.6.4 && @1.5.4 #899

Open
kishaningithub opened this issue Dec 20, 2023 · 15 comments
Open

unexpected error cannot intersect: @1.6.4 && @1.5.4 #899

kishaningithub opened this issue Dec 20, 2023 · 15 comments

Comments

@kishaningithub
Copy link
Contributor

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/libpkgx@v0.15.0/src/utils/semver.ts:382:30)
│     at condense (https://deno.land/x/libpkgx@v0.15.0/src/plumbing/hydrate.ts:78:33)
│     at hydrate (https://deno.land/x/libpkgx@v0.15.0/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

@jhheider
Copy link
Contributor

jhheider commented Dec 20, 2023

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.

@kishaningithub
Copy link
Contributor Author

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

@jhheider
Copy link
Contributor

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

@kishaningithub
Copy link
Contributor Author

Any ideas to fix this at a code level ? I can try contributing a PR for this

@jhheider
Copy link
Contributor

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.

@jhheider
Copy link
Contributor

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.

@jakobvase
Copy link
Contributor

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/libpkgx@v0.16.0/src/utils/semver.ts:384:30)
│     at hydrate (https://deno.land/x/libpkgx@v0.16.0/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

@kishaningithub
Copy link
Contributor Author

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

@mxcl
Copy link
Member

mxcl commented Jan 24, 2024

Sorry for this everyone. I’m actively figuring out solutions now.

@mxcl
Copy link
Member

mxcl commented Jan 24, 2024

K so this particular problem is in the dev shellcode. The unicode.org issue (^71 && ^73) is separate

@mxcl
Copy link
Member

mxcl commented Jan 24, 2024

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.

image

@jakobvase
Copy link
Contributor

jakobvase commented Jan 25, 2024

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

mxcl added a commit to pkgxdev/libpkgx that referenced this issue Jan 27, 2024
mxcl added a commit to pkgxdev/libpkgx that referenced this issue Jan 27, 2024
@mxcl
Copy link
Member

mxcl commented Jan 28, 2024

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.

@kishaningithub
Copy link
Contributor Author

@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 terraform@1.5.4 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)
Screenshot 2024-01-29 at 3 54 22 PM

Steps for simulation

  1. Install terraform using pkgx install terraform@1.5.4
  2. Create a terraform project mkdir -p terraform-repo && echo "1.6.4" > terraform-repo/.terraform-version
  3. cd terraform-repo
  4. dev
  5. Run terraform version - This will print out the right version (1.6.4) in the console without any errors
  6. Press "Cmd + D" to create a tab pane which will initialize with the same current working directory and type terraform version (screenshot below)
image

@mxcl
Copy link
Member

mxcl commented Jan 30, 2024

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?

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

No branches or pull requests

4 participants