Failed to build Move modules: "Unable to resolve packages for package 'my_first_package'" - move-lang

New to move and sui.
I am trying to follow the documentation on Sui and attempted to use the command sui move build to build my move package.
I encountered this error:
Failed to build Move modules: "Unable to resolve packages for package 'my_first_package'".
Attached picture below shows:
my folder structure in local.
the content of the .toml file.
sui cloned locally pointing to devnet branch.
attached picture

I solved my own problem, lol, by pointing Sui dependency correctly to sui-framework/ on local.
Content of .toml file:
[package]
name = "my_first_package"
version = "0.0.1"
[dependencies]
Sui = { local = "../sui/crates/sui-framework/"}
# { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework", rev = "devnet" }
[addresses]
my_first_package = "0x0"
sui = "0x2"
Originally, retrieving from git was taking too long to build so it might be better to git clone sui to local and build relying on local.

Afaik you don't need to define 'sui' as a named address in the .toml file at all.
[package]
name = "MyModule"
version = "0.0.1"
[dependencies]
Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework", rev = "devnet" }
[addresses]
my_module = "0x0"
works just fine

Related

How to get bazel/gazelle go_repository imports past go vet

I'm using bazel/gazelle to pull in some external git repositories.
For example:
go_repository(
name = "com_github_pkg_errors",
importpath = "github.com/pkg/errors",
sum = "h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=",
version = "v0.8.1",
)
My go file would just import github.com/pkg/errors like normal.
Problem comes when I run go vet on my file. It would complain that no such package exists under GOROOT or GOPATH. This repo is located in my bazel cache. ~/.cache/bazel/.../external/com_github_pkg_errors
How can I resolve this?
You have to specify the dependency in go.mod
require (
github.com/pkg/errors v0.8.1
)
In the BUILD.bazel file of your project, specify go_library with dep
go_library(
name = "project_lib",
srcs = [],
importpath = "github.com/pkg/errors",
visibility = ["//visibility:public"],
deps = [
"#com_github_pkg_errors",
],
)

Bazel build error with third party library - no such package

I'm using bazel 4.1.0 to build to project.
Current set up:
go.mod file
...
github.com/mwitkow/go-proto-validators v0.3.2 // indirect
...
WORKSPACE file
load("#bazel_gazelle//:deps.bzl", "gazelle_dependencies", "go_repository")
load("//:repositories.bzl", "go_repositories")
go_repositories()
in repositories.blz file
...
go_repository(
name = "com_github_mwitkow_go_proto_validators",
importpath = "github.com/mwitkow/go-proto-validators",
sum = "h1:qRlmpTzm2pstMKKzTdvwPCF5QfBNURSlAgN/R+qbKos=",
version = "v0.3.2",
)
....
in students/api.v1/api.proto file
import "google/api/annotations.proto";
import "github.com/mwitkow/go-proto-validators/validator.proto";
after running bazel run //:gazelle -- update-repos -from_file=go.mod -to_macro=repositories.bzl%go_repositories -prune=true and bazel run //:gazelle
it generate students/api.v1/BUILD.bazel file
proto_library(
name = "api_proto",
srcs = ["api.proto"],
visibility = ["//visibility:public"],
deps = [
"//github.com/mwitkow/go-proto-validators:validators_proto",
"#go_googleapis//google/api:annotations_proto",
],
)
go_proto_library(
name = "api_go_proto",
compilers = ["#io_bazel_rules_go//proto:go_grpc"],
importpath = "students/generated/api",
proto = ":api_proto",
visibility = ["//visibility:public"],
deps = [
"//github.com/mwitkow/go-proto-validators:validator_proto",
"#go_googleapis//google/api:annotations_go_proto",
],
)
When I run bazel build //..., it produces an error
ERROR: /my-app/students/api.v1/BUILD.bazel:15:17: no such package 'github.com/mwitkow/go-proto-validators': BUILD file not found in any of the following directories. Add a BUILD file to a directory to mark it as a package.
- /my-app/github.com/mwitkow/go-proto-validators and referenced by '/students/api.v1:api_go_proto'
ERROR: Analysis of target '//students/api.v1:api' failed; build aborted: Analysis failed
I would like to make the build work without error. Thank you very much for your help.
I think in BUILD.bazel file, //github.com/mwitkow/go-proto-validators:validators_proto should be #github.com/mwitkow/go-proto-validators:validators_proto, like #go_googleapis//google/api:annotations_proto but it's just a vague idea.

WASM/Yew - failed to resolve: could not find `unix` in `os`

Building Yew App on Windows
I'm building a yew app alongside a rocket backend on Windows following
this tutorial
(although the tutorial is for a Linux environment). I'm trying to build the yew app
using wasm-pack. I'm not using the Linux subsystem to build the app, though
I do have it installed.
Code / Configuration
The repository.
I have already installed the wasm toolchain and cargo make:
rustup target add wasm32-unknown-unknown
The following is my toolchain list:
stable-x86_64-pc-windows-gnu
stable-x86_64-pc-windows-msvc
nightly-x86_64-pc-windows-msvc (default)
1.30.0-x86_64-pc-windows-msvc
Here is my folder structure:
Project root
├───backend <-- rocket backend
| ├───Cargo.toml
│ └───src
│ ├───bin
│ └───db
├───frontend <-- yew frontend
│ ├───pkg
│ ├───src
| ├───Cargo.toml
| └───Makefile.toml
├───src
├───Cargo.toml
└───Makefile.toml
This is rootdir\Cargo.toml:
[package]
name = "sentinel"
version = "0.1.0"
authors = ["zachdelano <email>"]
edition = "2018"
[workspace]
members = ["backend", "frontend"]
This is rootdir\Makefile.toml:
[env]
CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = "true"
[tasks.default]
clear = true
dependencies = ["build"]
This is rootdir\frontend\Cargo.toml:
[dependencies]
sentinel = { path = ".." }
yew = "0.17.3"
wasm-pack = "0.9.1"
wasm-bindgen = "0.2.68"
web-sys = "0.3.45"
[lib]
crate-type = ["cdylib", "rlib"]
This is rootdir\frontend\Makefile.toml:
[tasks.default]
dependencies = ["create_wasm"]
[tasks.create_wasm]
command = "wasm-pack"
args = ["build", "--target", "web", "--out-name", "package", "--dev"]
dependencies = ["build"]
Expected result
I expect the app to finish building with no errors when I run
cargo make. The Yew tutorial
seems to indicate nothing else is needed.
Actual output
I get a host of errors when running cargo make (from the root directory) like the following:
error[E0433]: failed to resolve: could not find `unix` in `os`
--> C:\Users\Zach\.cargo\registry\src\github.com-1ecc6299db9ec823\dirs-1.0.5\src\lin.rs:41:18
|
41 | use std::os::unix::ffi::OsStringExt;
| ^^^^ could not find `unix` in `os`
See the entire list of errors.
Is this a toolchain sort of thing? How can I fix this?
Running rustup update
I get the following output
from running rustup update.
Now when I run cargo make from the root directory, I get different errors:
error[E0432]: unresolved import `crate::sys`
--> C:\Users\Zach\.cargo\registry\src\github.com-1ecc6299db9ec823\socket2-0.3.15\src\socket.rs:23:5
|
23 | use crate::sys;
| ^^^^^^^^^^ no `sys` in the root
See the full list of errors.
Some of the code changed in the repository.
The issue ended up being that I was trying to install wasm-pack and web-sys. I don't know why that was an issue but when I commented them out and ran cargo make, everything built just fine. I also deleted target and reran cargo make just to make sure.
[package]
name = "frontend"
version = "0.1.0"
authors = ["zachdelano <email>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
sentinel = { path = ".." }
yew = "0.17.3"
wasm-bindgen = "0.2.68"
# wasm-pack = "0.9.1"
# web-sys = "0.3.45"
[lib]
crate-type = ["cdylib", "rlib"]

'No such file or directory' error when using buildGoPackage in nix

I'm trying to build the hasura cli: https://github.com/hasura/graphql-engine/tree/master/cli with the following code (deps derived from dep2nix):
{ buildGoPackage, fetchFromGitHub }:
buildGoPackage rec {
version = "1.0.0-beta.2";
name = "hasura-${version}";
goPackagePath = "github.com/hasura/graphql-engine";
subPackages = [ "cli" ];
src = fetchFromGitHub {
owner = "hasura";
repo = "graphql-engine";
rev = "v${version}";
sha256 = "1b40s41idkp1nyb9ygxgsvrwv8rsll6dnwrifpn25bvnfk8idafr";
};
goDeps = ./deps.nix;
}
but I get the following errors after the post-installation fixup step:
find: '/nix/store/gkck68cm2z9k1qxgmh350pq3kwsbyn8q-hasura-cli-1.0.0-beta.2': No such file or directory.
What am I doing wrong here? For reference, I'm on macOS and using home-manager.
For anyone still wondering:
There are a couple of things to consider:
dep has been deprecated in favor of go modules
This is also reflected in Nix, as buildGoPackage is now legacy and moved to buildGoModule
There is already a hasura-cli package in nixpkgs. You can just use it with nix-shell -p hasura-cli

Bazel build is not working on from Maven project

I'm new to Bazel and learning its build work, currently I am trying to do with bazel build from a Maven project, please advise me how to make it working, thanks.
Here is the WORKSPACE file I am trying to define:
maven_jar(
name = "junit",
artifact = "junit:junit:3.8.1",
)
maven_jar(
name = "log4j1",
artifact = "org.apache.logging.log4j:log4j-core:2.6.2",
)
maven_jar(
name = "log4j2",
artifact = "org.apache.logging.log4j:log4j-api:2.6.2",
)
.....
Here is the BUILD file I am trying to define:
package(default_visibility = ["//visibility:public"])
java_binary(
name = "everything",
srcs = glob(["src/main/java/**/*.java"]),
resources = glob(["src/main/resources/**"]),
main_class = "src/main/java/com/test/test/test/App",
deps = [
"#junit//jar",
"#log4j1//jar",
"#log4j2//jar",
"#jackson//jar",
"#jsonsimple//jar",
"#commonsdbutils//jar",
"#commons//jar",
"#guava//jar",
"#poi//jar"],
)
Here is I got Bazel build results:
mbp:bazel_test me$ bazel build //:everything
INFO: Analysed target //:everything (1 packages loaded).
INFO: Found 1 target...
ERROR: /Users/me/git/test/test/BUILD:4:1: Building everything-class.jar (104 source files) failed (Exit 1)
src/main/java/com/test/test/test/Testapp.java:13: error: cannot find symbol
import org.apache.poi.ss.usermodel.Cell;
^
symbol: class Cell
location: program package org.apache.poi.ss.usermodel
.....
Target //:everything failed to build
I see two problems here:
The main_class attribute should use dots instead of slashes:
java_binary(
name = "everything",
srcs = glob(["src/main/java/**/*.java"]),
main_class = "src.main.java.com.test.test.test.App",
...
There's no org.apache.poi.ss.usermodel.Cell class in the poi jar.
Find the jar's name:
$ bazel query --output=build #poi//jar
...
java_import(
name = "jar",
visibility = ["//visibility:public"],
jars = ["#poi//jar:poi-ooxml-3.9.jar"],
srcjar = "#poi//jar:poi-ooxml-3.9-sources.jar",
)
The package's location is $(bazel info output_base)/external/poi, and now we know (from the srcs attribute in the bazel query output above) that the file is called poi-ooxml-3.9.jar:
$ unzip -l $(bazel info output_base)/external/poi/jar/poi-ooxml-3.9.jar | grep "org.apache.poi.ss.usermodel"
0 2012-11-26 17:14 org/apache/poi/ss/usermodel/
2970 2012-11-26 17:14 org/apache/poi/ss/usermodel/WorkbookFactory.class

Resources