Skip to content
This repository has been archived by the owner on Oct 13, 2023. It is now read-only.

Running cargo commands in a subdirectory? #86

Open
2 of 3 tasks
jduan opened this issue Jun 6, 2020 · 12 comments
Open
2 of 3 tasks

Running cargo commands in a subdirectory? #86

jduan opened this issue Jun 6, 2020 · 12 comments
Labels
enhancement New feature or request

Comments

@jduan
Copy link

jduan commented Jun 6, 2020

Do the checklist before filing an issue:

Motivation

My understanding is this github action only supports running cargo commands from the root of the repo. Is it possible to run cargo commands from a subdirectory? The motivation is that I have a monorepo that has projects that use different languages. I'd like to run cargo commands only for the rust projects.

Additional context

I've tried to set "working-directory" at the top level but that didn't seem to work.

@jduan jduan added the enhancement New feature or request label Jun 6, 2020
@Gottox
Copy link

Gottox commented Jul 5, 2020

This is also needed if you have a workspace project and want to tests with feature flags:

$ cargo test --features 'env'          
error: --features is not allowed in the root of a virtual workspace
note: while this was previously accepted, it didn't actually do anything

@Gottox
Copy link

Gottox commented Jul 5, 2020

Actually, while digging through the source, I suspect this is an actual bug in https://github.com/actions/toolkit. If you look at this comment, it states that if cwd is unset, it defaults to the current working directory, which is set by the working-directory option in the yaml:

https://github.com/actions/toolkit/blob/ea503a235e2ad9ef6aada2f72d62cbed17d31c76/packages/exec/src/interfaces.ts#L6-L7

Gottox added a commit to Gottox/lexoffice that referenced this issue Jul 5, 2020
Gottox added a commit to Gottox/lexoffice that referenced this issue Jul 5, 2020
@lisheeghan
Copy link

Perhaps this works?

      - name: Run cargo check
        uses: actions-rs/cargo@v1
        with:
          command: check
          args: --manifest-path dir1/dir2/Cargo.toml

@Gottox
Copy link

Gottox commented Aug 3, 2020

This works around this issue. Nevertheless I think this is a bug.

@qwandor
Copy link

qwandor commented Oct 27, 2020

I could also use a way to run cargo commands from a subdirectory, especially when using cargo deb which has a bug (mmstick/cargo-deb#151) where it doesn't work properly if run from the workspace root.

@huangjj27
Copy link

huangjj27 commented Feb 21, 2021

I have a same requirement as to publish crates onto crates.io in a workspace through an action trigger.

@unizippro
Copy link

So it seems we are waiting for #59 to be merged.
As a workaround one could use marco-polos branch

martin-g added a commit to martin-g/avro that referenced this issue Jul 8, 2021
Use --manifest-path to specify the path to Cargo.yaml
iemejia pushed a commit to apache/avro that referenced this issue Aug 7, 2021
* AVRO-3175 Rust: fix lint/clippy errors

Fix all linting/clippy errors & warnings.
Add build.sh for Rust that currently supports clean, dist, lint and test targets

* INFRA-22085 Test actions-rs

* AVRO-3175 Build with all features enabled

* AVRO-3175 Change working folder to lang/rust

* AVRO-3175 Set working folder to lang/avro for GHA

* [squash] Debug pwd

* AVRO-3175 Workaround actions-rs/cargo#86

Use --manifest-path to specify the path to Cargo.yaml

* AVRO-3175 Format the code with `cargo fmt --all --"

This should fix the Github Actions CI workflow

* AVRO-3175 Specify the path to Cargo.yaml for clippy
a0x8o added a commit to a0x8o/avro that referenced this issue Aug 9, 2021
* AVRO-3175 Rust: fix lint/clippy errors

Fix all linting/clippy errors & warnings.
Add build.sh for Rust that currently supports clean, dist, lint and test targets

* INFRA-22085 Test actions-rs

* AVRO-3175 Build with all features enabled

* AVRO-3175 Change working folder to lang/rust

* AVRO-3175 Set working folder to lang/avro for GHA

* [squash] Debug pwd

* AVRO-3175 Workaround actions-rs/cargo#86

Use --manifest-path to specify the path to Cargo.yaml

* AVRO-3175 Format the code with `cargo fmt --all --"

This should fix the Github Actions CI workflow

* AVRO-3175 Specify the path to Cargo.yaml for clippy
hkennyv added a commit to hkennyv/aoc that referenced this issue Nov 22, 2021
* CHORE: re-org years

* CHORE: fix ci? settings working-directory using '--manifest-path'

actions-rs/cargo#86 (comment)

* CHORE: oops, forgot build.yml
@lukepighetti
Copy link

I also expected this to use

defaults:
  run:
    working-directory: my-rust-project

As the working directory for where cargo run is run

@lpil
Copy link

lpil commented Oct 13, 2022

Is there a way to do this? I cannot set the manifest path as that's not the directory I wish to run cargo from. 🙏

@rherrmannr
Copy link

@lpil yes, as others stated you could use the --manifest-path:

cargo build --manifest-path /path/to/your/Cargo.toml

@ryankurte
Copy link

it'd still be neat to have this! --manifest-path doesn't work correctly with .cargo/config.toml and is usually broken when cross-compiling

@goughjo02
Copy link

I ended up changing it to this

Screenshot 2023-04-12 at 13 25 10

BrianCraig added a commit to BrianCraig/manrf that referenced this issue Apr 26, 2023
adamchalmers added a commit to KittyCAD/kcl-experiments that referenced this issue Jul 18, 2023
- Fix typos in CI yaml
- Due to actions-rs/cargo#86 the cargo actions cannot be configured to run in the `compiler/` dir, so it's easier to just move the compiler into the root of the repo.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Development

No branches or pull requests