average-australia-85137
08/24/2021, 8:30 PMhundreds-father-404
08/24/2021, 8:35 PMnpm
to be already installed similar to how Python interpreter selection works. And then for each tool, have a dedicated package.json
and corresponding lockfile. The package.json
would be created behind-the-scenes by reading the option [prettier].version
etc. The lockfile should probably be checked-in on disk, similar to what we're doing for Python "tool lockfiles" like [black].lockfile
I also want to investigate using yarn
instead of npm
average-australia-85137
08/24/2021, 8:42 PMhundreds-father-404
08/24/2021, 8:51 PM[prettier].version
and [webpack].version
in pants.toml
.
We also want to make sure installing tools is determistic, so we need to support using the lockfiles from NPM/Yarn, and those should be saved on disk and checked into VCS.
The individual package.json
piece is that Pants will convert your options like [prettier].version
into a package.json
for you, without it being saved to disk. It happens behind-the-scenes. But the user gets back a way to run tools like Prettier/Webpack, along with a lockfile they can check in. Does that make sense?average-australia-85137
08/24/2021, 8:54 PMhundreds-father-404
08/24/2021, 9:03 PMaverage-australia-85137
08/24/2021, 9:33 PMhundreds-father-404
08/24/2021, 9:36 PMaverage-australia-85137
08/27/2021, 7:06 PMnpm install
to install webpack however I am getting the error:
Exception message: 1 Exception encountered:
ProcessExecutionFailure: Process 'installing webpack' failed with exit code 127.
stdout:
stderr:
env: node: No such file or directory
it looks like node needs to be in the environment cause npm shells out to it. Is there a good way to execute npm with node in the environment?happy-kitchen-89482
08/28/2021, 5:13 PMnode
? Is it on your $PATH
?happy-kitchen-89482
08/28/2021, 5:14 PMhappy-kitchen-89482
08/28/2021, 5:14 PMhappy-kitchen-89482
08/28/2021, 5:19 PMdocker
binary, for examplehappy-kitchen-89482
08/28/2021, 5:19 PMaverage-australia-85137
08/30/2021, 1:28 PM<http://logger.info|logger.info>("Getting npm")
nvm_bin = await Get(Environment, EnvironmentRequest(["NVM_BIN"]))
<http://logger.info|logger.info>(nvm_bin)
search_path = ["/bin", "/usr/bin", "/usr/local/bin"]
if nvm_bin:
search_path = [nvm_bin.get('NVM_BIN')]
npm_path, node_path = await MultiGet(
Get(
BinaryPaths,
BinaryPathRequest(
binary_name="npm",
search_path=search_path,
),
),
Get(
BinaryPaths,
BinaryPathRequest(
binary_name="node",
search_path=search_path,
),
),
)
<http://logger.info|logger.info>(npm_path)
process_path = npm_path.first_path.path
<http://logger.info|logger.info>(process_path)
<http://logger.info|logger.info>(node_path.first_path.path)
# PATH = node_path.first_path.path
# node_binary_location = await Get(Snapshot, PathGlobs([" ../../.nvm/versions/node/v10.15.1/bin/*"]))
# <http://logger.info|logger.info>(PATH)
# <http://logger.info|logger.info>(node_binary_location.files)
process_result = await Get(
ProcessResult,
Process(
argv=[process_path, "install", "webpack", "webpack-cli", "--save"],
env={"PATH":tuple(search_path)},
input_digest=node_binary_location.digest,
description="installing webpack"
),
)
<http://logger.info|logger.info>(process_result)
output
09:27:50.63 [INFO] Getting npm
09:27:50.63 [INFO] FrozenDict({'NVM_BIN': '/Users/nate/.nvm/versions/node/v10.15.1/bin'})
09:27:50.80 [INFO] BinaryPaths(binary_name='npm', paths=(BinaryPath(path='/Users/nate/.nvm/versions/node/v10.15.1/bin/npm', fingerprint='e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'),))
09:27:50.80 [INFO] /Users/nate/.nvm/versions/node/v10.15.1/bin/npm
09:27:50.80 [INFO] /Users/nate/.nvm/versions/node/v10.15.1/bin/node
09:27:50.81 [INFO] Completed: installing webpack
09:27:50.82 [ERROR] Exception caught: (pants.engine.internals.scheduler.ExecutionError)
File "/Users/nate/.cache/pants/setup/bootstrap-Darwin-x86_64/pants.zsCKZK/install/lib/python3.9/site-packages/pants/bin/local_pants_runner.py", line 234, in _run_inner
return self._perform_run(goals)
File "/Users/nate/.cache/pants/setup/bootstrap-Darwin-x86_64/pants.zsCKZK/install/lib/python3.9/site-packages/pants/bin/local_pants_runner.py", line 173, in _perform_run
return self._perform_run_body(goals, poll=False)
File "/Users/nate/.cache/pants/setup/bootstrap-Darwin-x86_64/pants.zsCKZK/install/lib/python3.9/site-packages/pants/bin/local_pants_runner.py", line 190, in _perform_run_body
return self.graph_session.run_goal_rules(
File "/Users/nate/.cache/pants/setup/bootstrap-Darwin-x86_64/pants.zsCKZK/install/lib/python3.9/site-packages/pants/init/engine_initializer.py", line 135, in run_goal_rules
exit_code = self.scheduler_session.run_goal_rule(
File "/Users/nate/.cache/pants/setup/bootstrap-Darwin-x86_64/pants.zsCKZK/install/lib/python3.9/site-packages/pants/engine/internals/scheduler.py", line 530, in run_goal_rule
self._raise_on_error([t for _, t in throws])
File "/Users/nate/.cache/pants/setup/bootstrap-Darwin-x86_64/pants.zsCKZK/install/lib/python3.9/site-packages/pants/engine/internals/scheduler.py", line 498, in _raise_on_error
raise ExecutionError(
Exception message: 1 Exception encountered:
ProcessExecutionFailure: Process 'installing webpack' failed with exit code 127.
stdout:
stderr:
env: node: No such file or directory
average-australia-85137
08/30/2021, 1:29 PMaverage-australia-85137
08/30/2021, 2:17 PMhappy-kitchen-89482
08/30/2021, 3:26 PMenv={"PATH":tuple(search_path)}
, don't you want env={"PATH": os.pathsep.join(search_path)}
?happy-kitchen-89482
08/30/2021, 3:27 PM('/Users/nate/.nvm/versions/node/v10.15.1/bin',)
and if so, I'm not surprised it can't find the binaries...hundreds-father-404
08/30/2021, 5:18 PMIf I decide to go the external tool route is there a way to determine what processor we are running on?Yeah, the
Platform
type is CPU arch x OS. See platform.py
average-australia-85137
08/30/2021, 5:59 PM./install_dir/bin
or /node_modules/bin
)hundreds-father-404
08/30/2021, 6:00 PMwitty-crayon-22786
08/30/2021, 6:04 PMwitty-crayon-22786
08/30/2021, 6:07 PM--no-process-execution-local-cleanup
should allow you to inspect the sandbox, but in general: process execution / snapshotting in Pants doesn’t capture or materialize symlinks as symlinks.witty-crayon-22786
08/30/2021, 6:07 PMaverage-australia-85137
08/30/2021, 6:13 PM