open-rmf / rmf_site

Experimental visualizer for dense buildings in RMF
32 stars 13 forks source link

[Bug]: failed to resolve: use of undeclared crate or module `bevy` with colcon build #158

Closed Yadunund closed 1 year ago

Yadunund commented 1 year ago

Before proceeding, is there an existing issue or discussion for this?

OS and version

MacOS 13.4

Open-RMF installation type

Source build

Other Open-RMF installation methods

No response

Open-RMF version or commit hash

NA

ROS distribution

Rolling

ROS installation type

Binaries

Other ROS installation methods

No response

Package or library, if applicable

No response

Description of the bug

colcon cannot find the bevy module

Starting >>> rmf_site_format
--- stderr: rmf_site_format                         
error[E0433]: failed to resolve: use of undeclared crate or module `bevy`
   --> rmf_site_format/src/misc.rs:128:34
    |
128 | #[derive(Serialize, Deserialize, bevy::prelude::Deref, DerefMut, PartialEq, Clone, Debug)]
    |                                  ^^^^ use of undeclared crate or module `bevy`

error: cannot find derive macro `DerefMut` in this scope
   --> rmf_site_format/src/misc.rs:128:56
    |
128 | #[derive(Serialize, Deserialize, bevy::prelude::Deref, DerefMut, PartialEq, Clone, Debug)]
    |                                                        ^^^^^^^^

error[E0412]: cannot find type `Entity` in this scope
  --> rmf_site_format/src/workcell.rs:74:45
   |
74 | pub struct ConstraintDependents(pub HashSet<Entity>);
   |                                             ^^^^^^ not found in this scope
   |
help: you might be missing a type parameter
   |
74 | pub struct ConstraintDependents<Entity>(pub HashSet<Entity>);
   |                                ++++++++

error[E0412]: cannot find type `Entity` in this scope
  --> rmf_site_format/src/workcell.rs:74:45
   |
74 | pub struct ConstraintDependents(pub HashSet<Entity>);
   |                                             ^^^^^^ not found in this scope

error[E0277]: the trait bound `glam::Vec3: Serialize` is not satisfied
   --> rmf_site_format/src/misc.rs:128:10
    |
128 | #[derive(Serialize, Deserialize, bevy::prelude::Deref, DerefMut, PartialEq, Clone, Debug)]
    |          ^^^^^^^^^ the trait `Serialize` is not implemented for `glam::Vec3`
129 | #[cfg_attr(feature = "bevy", derive(Component))]
130 | pub struct Scale(pub Vec3);
    |                  --- required by a bound introduced by this call
    |
    = help: the following other types implement trait `Serialize`:
              &'a T
              &'a mut T
              ()
              (T0, T1)
              (T0, T1, T2)
              (T0, T1, T2, T3)
              (T0, T1, T2, T3, T4)
              (T0, T1, T2, T3, T4, T5)
            and 261 others
note: required by a bound in `serialize_newtype_struct`
   --> /Users/yadunund/.cargo/registry/src/index.crates.io-6f17d22bba15001f/serde-1.0.164/src/ser/mod.rs:906:12
    |
900 |     fn serialize_newtype_struct<T: ?Sized>(
    |        ------------------------ required by a bound in this associated function
...
906 |         T: Serialize;
    |            ^^^^^^^^^ required by this bound in `Serializer::serialize_newtype_struct`

error[E0277]: the trait bound `glam::Vec3: Deserialize<'_>` is not satisfied
   --> rmf_site_format/src/misc.rs:130:18
    |
130 | pub struct Scale(pub Vec3);
    |                  ^^^ the trait `Deserialize<'_>` is not implemented for `glam::Vec3`
    |
    = help: the following other types implement trait `Deserialize<'de>`:
              &'a [u8]
              &'a std::path::Path
              &'a str
              ()
              (T0, T1)
              (T0, T1, T2)
              (T0, T1, T2, T3)
              (T0, T1, T2, T3, T4)
            and 260 others

error[E0277]: the trait bound `glam::Vec3: Deserialize<'_>` is not satisfied
    --> rmf_site_format/src/misc.rs:130:22
     |
130  | pub struct Scale(pub Vec3);
     |                      ^^^^ the trait `Deserialize<'_>` is not implemented for `glam::Vec3`
     |
     = help: the following other types implement trait `Deserialize<'de>`:
               &'a [u8]
               &'a std::path::Path
               &'a str
               ()
               (T0, T1)
               (T0, T1, T2)
               (T0, T1, T2, T3)
               (T0, T1, T2, T3, T4)
             and 260 others
note: required by a bound in `next_element`
    --> /Users/yadunund/.cargo/registry/src/index.crates.io-6f17d22bba15001f/serde-1.0.164/src/de/mod.rs:1729:12
     |
1727 |     fn next_element<T>(&mut self) -> Result<Option<T>, Self::Error>
     |        ------------ required by a bound in this associated function
1728 |     where
1729 |         T: Deserialize<'de>,
     |            ^^^^^^^^^^^^^^^^ required by this bound in `SeqAccess::next_element`

error[E0277]: the trait bound `glam::Vec3: Serialize` is not satisfied
    --> rmf_site_format/src/workcell.rs:128:9
     |
127  |         #[serde(default, skip_serializing_if = "is_default")]
     |         - required by a bound introduced by this call
128  |         scale: Option<Vec3>,
     |         ^^^^^ the trait `Serialize` is not implemented for `glam::Vec3`
     |
     = help: the following other types implement trait `Serialize`:
               &'a T
               &'a mut T
               ()
               (T0, T1)
               (T0, T1, T2)
               (T0, T1, T2, T3)
               (T0, T1, T2, T3, T4)
               (T0, T1, T2, T3, T4, T5)
             and 261 others
     = note: required for `std::option::Option<glam::Vec3>` to implement `Serialize`
note: required by a bound in `agent::_::_serde::ser::SerializeStructVariant::serialize_field`
    --> /Users/yadunund/.cargo/registry/src/index.crates.io-6f17d22bba15001f/serde-1.0.164/src/ser/mod.rs:1967:12
     |
1961 |     fn serialize_field<T: ?Sized>(
     |        --------------- required by a bound in this associated function
...
1967 |         T: Serialize;
     |            ^^^^^^^^^ required by this bound in `SerializeStructVariant::serialize_field`

error[E0277]: the trait bound `glam::Vec3: Deserialize<'_>` is not satisfied
    --> rmf_site_format/src/workcell.rs:128:16
     |
128  |         scale: Option<Vec3>,
     |                ^^^^^^^^^^^^ the trait `Deserialize<'_>` is not implemented for `glam::Vec3`
     |
     = help: the following other types implement trait `Deserialize<'de>`:
               &'a [u8]
               &'a std::path::Path
               &'a str
               ()
               (T0, T1)
               (T0, T1, T2)
               (T0, T1, T2, T3)
               (T0, T1, T2, T3, T4)
             and 273 others
     = note: required for `std::option::Option<glam::Vec3>` to implement `Deserialize<'_>`
note: required by a bound in `next_element`
    --> /Users/yadunund/.cargo/registry/src/index.crates.io-6f17d22bba15001f/serde-1.0.164/src/de/mod.rs:1729:12
     |
1727 |     fn next_element<T>(&mut self) -> Result<Option<T>, Self::Error>
     |        ------------ required by a bound in this associated function
1728 |     where
1729 |         T: Deserialize<'de>,
     |            ^^^^^^^^^^^^^^^^ required by this bound in `SeqAccess::next_element`

error[E0277]: the trait bound `glam::Vec3: Deserialize<'_>` is not satisfied
    --> rmf_site_format/src/workcell.rs:128:16
     |
128  |         scale: Option<Vec3>,
     |                ^^^^^^^^^^^^ the trait `Deserialize<'_>` is not implemented for `glam::Vec3`
     |
     = help: the following other types implement trait `Deserialize<'de>`:
               &'a [u8]
               &'a std::path::Path
               &'a str
               ()
               (T0, T1)
               (T0, T1, T2)
               (T0, T1, T2, T3)
               (T0, T1, T2, T3, T4)
             and 273 others
     = note: required for `std::option::Option<glam::Vec3>` to implement `Deserialize<'_>`
note: required by a bound in `next_value`
    --> /Users/yadunund/.cargo/registry/src/index.crates.io-6f17d22bba15001f/serde-1.0.164/src/de/mod.rs:1868:12
     |
1866 |     fn next_value<V>(&mut self) -> Result<V, Self::Error>
     |        ---------- required by a bound in this associated function
1867 |     where
1868 |         V: Deserialize<'de>,
     |            ^^^^^^^^^^^^^^^^ required by this bound in `MapAccess::next_value`

error[E0599]: no method named `iter` found for struct `location::LocationTags` in the current scope
   --> rmf_site_format/src/legacy/nav_graph.rs:175:42
    |
175 |         props.is_charger = location.tags.iter().find(|t| t.is_charger()).is_some();
    |                                          ^^^^ method not found in `LocationTags`
    |
   ::: rmf_site_format/src/location.rs:78:1
    |
78  | pub struct LocationTags(pub Vec<LocationTag>);
    | ----------------------- method `iter` not found for this struct
    |
help: one of the expressions' fields has a method of the same name
    |
175 |         props.is_charger = location.tags.0.iter().find(|t| t.is_charger()).is_some();
    |                                          ++

error[E0599]: no method named `iter` found for struct `location::LocationTags` in the current scope
   --> rmf_site_format/src/legacy/nav_graph.rs:178:14
    |
176 |           props.is_holding_point = location
    |  __________________________________-
177 | |             .tags
178 | |             .iter()
    | |             -^^^^ method not found in `LocationTags`
    | |_____________|
    | 
    |
   ::: rmf_site_format/src/location.rs:78:1
    |
78  |   pub struct LocationTags(pub Vec<LocationTag>);
    |   ----------------------- method `iter` not found for this struct
    |
help: one of the expressions' fields has a method of the same name
    |
178 |             .0.iter()
    |              ++

error[E0599]: no method named `iter` found for struct `location::LocationTags` in the current scope
   --> rmf_site_format/src/legacy/nav_graph.rs:181:47
    |
181 |         props.is_parking_spot = location.tags.iter().find(|t| t.is_parking_spot()).is_some();
    |                                               ^^^^ method not found in `LocationTags`
    |
   ::: rmf_site_format/src/location.rs:78:1
    |
78  | pub struct LocationTags(pub Vec<LocationTag>);
    | ----------------------- method `iter` not found for this struct
    |
help: one of the expressions' fields has a method of the same name
    |
181 |         props.is_parking_spot = location.tags.0.iter().find(|t| t.is_parking_spot()).is_some();
    |                                               ++

Some errors have detailed explanations: E0277, E0412, E0433, E0599.
For more information about an error, try `rustc --explain E0277`.
error: could not compile `rmf_site_format` (lib) due to 13 previous errors
---
Failed   <<< rmf_site_format [5.80s, exited with code 1]

Steps to reproduce the bug

Install these plugins for cargo and colcon:

cargo install --debug cargo-ament-build # --debug is faster to install pip install git+https://github.com/colcon/colcon-cargo.git pip install git+https://github.com/colcon/colcon-ros-cargo.git

create a workspace with rmf_site checked out to yadu/ament_cargo branch and build workspace with colcon build

Expected behavior

No response

Actual behavior

No response

Additional information or screenshots

Another error encountered is colcon failing to parse the workspace Cargo.toml since it does not have the [dependencies] key. But adding this key without any values (virtual deps) is not permitted.

[0.780s] ERROR:colcon.colcon_core.package_identification:Exception in package identification extension 'cargo' in 'src/rmf_site': 'dependencies'
Traceback (most recent call last):
  File "/Users/yadunund/.pyenv/versions/3.10.0/lib/python3.10/site-packages/colcon_core/package_identification/__init__.py", line 142, in _identify
    retval = extension.identify(_reused_descriptor_instance)
  File "/Users/yadunund/.local/lib/python3.10/site-packages/colcon_cargo/package_identification/cargo.py", line 30, in identify
    data = extract_data(cargo_toml)
  File "/Users/yadunund/.local/lib/python3.10/site-packages/colcon_cargo/package_identification/cargo.py", line 64, in extract_data
    depends = extract_dependencies(content)
  File "/Users/yadunund/.local/lib/python3.10/site-packages/colcon_cargo/package_identification/cargo.py", line 93, in extract_dependencies
    return list(content['dependencies'].keys())
KeyError: 'dependencies'