GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Incorrect work on Linux (`Error: `resolve` must be run directly as an executable`) · Issue #316 · browserify/resolve

Incorrect work on Linux (Error: resolve must be run directly as an executable) #316

New issue
Copy link
New issue
Copy link
Closed
Closed
Incorrect work on Linux (Error: resolve must be run directly as an executable)#316
Copy link

Description

@vvscode
vvscode
opened on Sep 15, 2023
Issue body actions

As continue to #315

I faced a problem, when locally(on Mac) everything works, and on CI (Linux) - not I got Error: resolve must be run directly as an executable

after some investigation I discovered that

// DEBUG PATCH
console.log('@@resolve debug info:', JSON.stringify({
    npm_lifecycle_script: process.env.npm_lifecycle_script,
    argv: process.argv,
    __filename,
    ino1: fs.statSync(process.argv[1]).ino,
    ino2: fs.statSync(__filename).ino,
    _: process.env._,
    realpathSync: fs.realpathSync(path.resolve(process.env._))
}, null, 2), { version: pkg.version});

// ---------

if (
    String(process.env.npm_lifecycle_script).slice(0, 8) !== 'resolve '
    && (
        !process.argv
        || process.argv.length < 2
        || (process.argv[1] !== __filename && fs.statSync(process.argv[1]).ino !== fs.statSync(__filename).ino)
        || (process.env._ && fs.realpathSync(path.resolve(process.env._)) !== __filename)
    )
) {
    console.error('Error: `resolve` must be run directly as an executable');
    process.exit(1);
}

gives me different results in section _ (process.env._)

On Mac (locally):

➜  tmp npx resolve 123
@@resolve debug info: {
  "npm_lifecycle_script": "resolve",
  "argv": [
    "/opt/homebrew/Cellar/node/20.6.0/bin/node",
    "/Users/v.vanchuk/repo/tmp/node_modules/.bin/resolve",
    "123"
  ],
  "__filename": "/Users/v.vanchuk/repo/tmp/node_modules/resolve-with-debug/bin/resolve",
  "ino1": 4677520,
  "ino2": 4677520,
  "_": "/Users/v.vanchuk/repo/tmp/node_modules/.bin/resolve",
  "realpathSync": "/Users/v.vanchuk/repo/tmp/node_modules/resolve-with-debug/bin/resolve"
} { version: '1.22.10' }
/Users/v.vanchuk/repo/tmp/node_modules/resolve-with-debug/lib/sync.js:115
    throw err;
    ^

Error: Cannot find module '123' from '/Users/v.vanchuk/repo/tmp'

On Linux (I used github codespaces to reproduce):

@vvscode ➜ /workspaces/codespaces-blank $ npx resolve 123
@@resolve debug info: {
  "npm_lifecycle_script": "resolve",
  "argv": [
    "/usr/local/share/nvm/versions/node/v20.6.1/bin/node",
    "/workspaces/codespaces-blank/node_modules/.bin/resolve",
    "123"
  ],
  "__filename": "/workspaces/codespaces-blank/node_modules/resolve-with-debug/bin/resolve",
  "ino1": 1453838,
  "ino2": 1453838,
  "_": "/home/codespace/nvm/current/bin/npx",
  "realpathSync": "/usr/local/share/nvm/versions/node/v20.6.1/lib/node_modules/npm/bin/npx-cli.js"
} { version: '1.22.10' }
Error: `resolve` must be run directly as an executable

Steps to reproduce:

  • create empty project with npm init -y
  • add latest version of resolve with yarn add resolve@latest
  • run yarn run resolve 123
  • run npx resolve 123

Activity

  1. ljharb
    closed this as completedin 1e230d1on Sep 15, 2023
  2. ljharb
    added 3 commits that reference this issue on Sep 15, 2023

    [Fix] allow `npx resolve` to work (#316)

    343ea44

    v1.22.6

    2ae67c1

    Merge tag 'v1.22.6'

    a9c252e
  3. ljharb
    added a commit that references this issue on Oct 10, 2023

    v2.0.0-next.5

    284daba
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.