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

no supported workflow for installing from npm #3857

Closed
dckc opened this issue Sep 20, 2021 · 10 comments · Fixed by #4129 or #4236
Closed

no supported workflow for installing from npm #3857

dckc opened this issue Sep 20, 2021 · 10 comments · Fixed by #4129 or #4236
Assignees
Labels
bug Something isn't working devex developer experience vaults_triage DO NOT USE

Comments

@dckc
Copy link
Member

dckc commented Sep 20, 2021

Describe the bug

We don't have a supported workflow of building dapps by installing packages such as @agoric/zoe from npm. Only building from source is adequately supported.

For example, the agoric cli is installed using yarn link-cli, unlike other npm tools that are installed using npm install -g or the like.

To Reproduce

If you run agoric install from inside an agoric-sdk, you're in a world of hurt.

If you then make a new agoric-sdk clone, forgetting to yarn link-cli leads to difficult-to-diagnose version skew (this cost @dtribble a bunch of time today).

npx agoric init demo doesn't work:

$ npx agoric init demo
npm ERR! code ENOENT
npm ERR! syscall chmod
npm ERR! path /home/gitpod/.npm/_npx/1639/lib/node_modules/agoric/bin/agoric
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, chmod '/home/gitpod/.npm/_npx/1639/lib/node_modules/agoric/bin/agoric'

running agoric with a pre-ESM version gives a pretty bad diagnostic:

$ agoric
/home/connolly/projects/agoric/agoric-sdk/packages/agoric-cli/lib/entrypoint.js:6
import 'esm';
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at Module._compile (internal/modules/cjs/loader.js:895:18)

Expected behavior

like other dev tools in the npm world

cc @mhofman @katelynsills @warner @michaelfig

@dckc dckc added bug Something isn't working devex developer experience labels Sep 20, 2021
@dckc dckc self-assigned this Sep 20, 2021
@michaelfig
Copy link
Member

The agoric cli is installed using yarn link-cli, unlike other npm tools that are installed using npm install -g or the like.

We can certainly make npm install -g agoric and yarn global add agoric work (again), but that can only use the latest published NPM version of the SDK, and hence is inappropriate for rapid development.

Be aware that if you want to use an existing checkout of agoric-sdk and have it immediately use any of your changes, there will always need to be a special case for that, whether:

a. Use yarn link-cli
b. Set some environment variable to point to the SDK
c. Install the SDK in a conventional location
d. Explicitly run .../agoric-sdk/packages/agoric-cli/bin/agoric or some other entrypoint within the SDK
e. Something else?

Pick your poison.

@mhofman
Copy link
Member

mhofman commented Sep 21, 2021

The agoric cli is installed using yarn link-cli, unlike other npm tools that are installed using npm install -g or the like.

We can certainly make npm install -g agoric and yarn global add agoric work (again), but that can only use the latest published NPM version of the SDK, and hence is inappropriate for rapid development.

The usual workflow for this is yarn link. Maybe a possible flow for an agoric-cli package globally installed would be:

  • (optional, in agoric-sdk) yarn link-cli: setup global link for the agoric-cli from this sdk location.
  • agoric use-sdk [sdk-path] (in dapp): sets up yarn links for this project, using the sdk path the agoric-cli is coming from if above step was done and no specific path was provided. It'd replace agoric install, and would be use once (TBD: I'm not sure what a yarn install does after a yarn link)
  • other agoric commands defer to the agoric-cli of the local project (equivalent to npx agoric)

Be aware that if you want to use an existing checkout of agoric-sdk and have it immediately use any of your changes, there will always need to be a special case for that, whether:

a. Use yarn link-cli
b. Set some environment variable to point to the SDK
c. Install the SDK in a conventional location
d. Explicitly run .../agoric-sdk/packages/agoric-cli/bin/agoric or some other entrypoint within the SDK
e. Something else?

Pick your poison.

npx agoric will pick ./node_modules/.bin/agoric if agoric-cli is installed as a dependency, either from registry or from yarn link.

@dckc
Copy link
Member Author

dckc commented Dec 11, 2021

@mhofman reports that we're not quite there yet: #4129 (comment)

@dckc
Copy link
Member Author

dckc commented Feb 8, 2023

I ran into another person trying to do npm i @agoric/zoe like it says on https://www.npmjs.com/package/@agoric/zoe and it doesn't work.

@dckc dckc reopened this Feb 8, 2023
@dckc dckc changed the title agoric cli does not work like normal devDependencies npm install @agoric/zoe does not work Feb 8, 2023
@mhofman
Copy link
Member

mhofman commented Feb 8, 2023

We disabled the CI test that uses local-npm, so paint me not surprised.

@dckc
Copy link
Member Author

dckc commented Feb 8, 2023

I'm not surprised either; https://docs.agoric.com/guides/getting-started/ is the only currently supported path. This open issue is just an acknowledgement that we're behind market norms in this respect.

@dckc
Copy link
Member Author

dckc commented Nov 8, 2023

I tried using the SDK as normal npm packages in the context of some recent work on a smart-wallet style app starter, but I hit:

Cannot find module '.../simple-game/contract/node_modules/@agoric/swingset-liveslots/tools/fakeVirtualSupport.js'

looks like @agoric/swingset-liveslots doesn't include it in its npm package.

So I went back to agoric install style links :-/

p.s. my WIP: dc-test-contract agoric-labs/dapp-join-game@1a653c0

@mhofman
Copy link
Member

mhofman commented Nov 8, 2023

Known issue tracked in #8380 and which will be solved by #8390

@dckc
Copy link
Member Author

dckc commented Nov 29, 2023

@dckc dckc changed the title npm install @agoric/zoe does not work installing @agoric/zoe from npm does not work Dec 8, 2023
@dckc dckc changed the title installing @agoric/zoe from npm does not work no supported workflow for installing from npm Dec 12, 2023
@dckc dckc assigned kbennett2000 and unassigned dckc Dec 12, 2023
@dckc
Copy link
Member Author

dckc commented Dec 20, 2023

We now have a supported workflow based on yarn create ... from #8530 that works for at least one dapp . There are likely rough edges, but let's address those in other issues.

https://docs.agoric.com/guides/getting-started/ documents it as of 1cf164c

@dckc dckc closed this as completed Dec 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working devex developer experience vaults_triage DO NOT USE
Projects
None yet
5 participants