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

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

Related

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

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

In a setup with two Nix Flakes, where one provides a plugin for the other's application, "path <…> is not valid". How to fix that?

I have two Nix Flakes: One contains an application, and the other contains a plugin for that application. When I build the application with the plugin, I get the error
error: path '/nix/store/3b7djb5pr87zbscggsr7vnkriw3yp21x-mainapp-go-modules' is not valid
I have no idea what this error means and how to fix it, but I can reproduce it on both macOS and Linux. The path in question is the vendor directory generated by the first step of buildGoModule.
The minimal setup to reproduce the error requires a bunch of files, so I provide a commented bash script that you can execute in an empty folder to recreate my setup:
#!/bin/bash
# I have two flakes: the main application and a plugin.
# the mainapp needs to be inside the plugin directory
# so that nix doesn't complain about the path:mainapp
# reference being outside the parent's root.
mkdir -p plugin/mainapp
# each is a go module with minimal setup
tee plugin/mainapp/go.mod <<EOF >/dev/null
module example.com/mainapp
go 1.16
EOF
tee plugin/go.mod <<EOF >/dev/null
module example.com/plugin
go 1.16
EOF
# each contain minimal Go code
tee plugin/mainapp/main.go <<EOF >/dev/null
package main
import "fmt"
func main() {
fmt.Println("Hello, World!")
}
EOF
tee plugin/main.go <<EOF >/dev/null
package plugin
import log
func init() {
fmt.Println("initializing plugin")
}
EOF
# the mainapp is a flake that provides a function for building
# the app, as well as a default package that is the app
# without any plugins.
tee plugin/mainapp/flake.nix <<'EOF' >/dev/null
{
description = "main application";
inputs = {
nixpkgs.url = github:NixOS/nixpkgs/nixos-21.11;
flake-utils.url = github:numtide/flake-utils;
};
outputs = {self, nixpkgs, flake-utils}:
let
# buildApp builds the application from a list of plugins.
# plugins cause the vendorSha256 to change, hence it is
# given as additional parameter.
buildApp = { pkgs, vendorSha256, plugins ? [] }:
let
# this is appended to the mainapp's go.mod so that it
# knows about the plugin and where to find it.
requirePlugin = plugin: ''
require ${plugin.goPlugin.goModName} v0.0.0
replace ${plugin.goPlugin.goModName} => ${plugin.outPath}/src
'';
# since buildGoModule consumes the source two times –
# first for vendoring, and then for building –
# we do the necessary modifications to the sources in an
# own derivation and then hand that to buildGoModule.
sources = pkgs.stdenvNoCC.mkDerivation {
name = "mainapp-with-plugins-source";
src = self;
phases = [ "unpackPhase" "buildPhase" "installPhase" ];
# write a plugins.go file that references the plugin's package via
# _ = "<module path>"
PLUGINS_GO = ''
package main
// Code generated by Nix. DO NOT EDIT.
import (
${builtins.foldl' (a: b: a + "\n\t_ = \"${b.goPlugin.goModName}\"") "" plugins}
)
'';
GO_MOD_APPEND = builtins.foldl' (a: b: a + "${requirePlugin b}\n") "" plugins;
buildPhase = ''
printenv PLUGINS_GO >plugins.go
printenv GO_MOD_APPEND >>go.mod
'';
installPhase = ''
mkdir -p $out
cp -r -t $out *
'';
};
in pkgs.buildGoModule {
name = "mainapp";
src = builtins.trace "sources at ${sources}" sources;
inherit vendorSha256;
nativeBuildInputs = plugins;
};
in (flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
in rec {
defaultPackage = buildApp {
inherit pkgs;
# this may be different depending on your nixpkgs; if it is, just change it.
vendorSha256 = "sha256-pQpattmS9VmO3ZIQUFn66az8GSmB4IvYhTTCFn6SUmo=";
};
}
)) // {
lib = {
inherit buildApp;
# helper that parses a go.mod file for the module's name
pluginMetadata = goModFile: {
goModName = with builtins; head
(match "module ([^[:space:]]+).*" (readFile goModFile));
};
};
};
}
EOF
# the plugin is a flake depending on the mainapp that outputs a plugin package,
# and also a package that is the mainapp compiled with this plugin.
tee plugin/flake.nix <<'EOF' >/dev/null
{
description = "mainapp plugin";
inputs = {
nixpkgs.url = github:NixOS/nixpkgs/nixos-21.11;
flake-utils.url = github:numtide/flake-utils;
nix-filter.url = github:numtide/nix-filter;
mainapp.url = path:mainapp;
mainapp.inputs = {
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
};
};
outputs = {self, nixpkgs, flake-utils, nix-filter, mainapp}:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
in rec {
packages = rec {
plugin = pkgs.stdenvNoCC.mkDerivation {
pname = "mainapp-plugin";
version = "0.1.0";
src = nix-filter.lib.filter {
root = ./.;
exclude = [ ./mainapp ./flake.nix ./flake.lock ];
};
# needed for mainapp to recognize this as plugin
passthru.goPlugin = mainapp.lib.pluginMetadata ./go.mod;
phases = [ "unpackPhase" "installPhase" ];
installPhase = ''
mkdir -p $out/src
cp -r -t $out/src *
'';
};
app = mainapp.lib.buildApp {
inherit pkgs;
# this may be different depending on your nixpkgs; if it is, just change it.
vendorSha256 = "sha256-a6HFGFs1Bu9EkXwI+DxH5QY2KBcdPzgP7WX6byai4hw=";
plugins = [ plugin ];
};
};
defaultPackage = packages.app;
}
);
}
EOF
You need Nix with Flake support installed to reproduce the error.
In the plugin folder created by this script, execute
$ nix build
trace: sources at /nix/store/d5arinbiaspyjjc4ypk4h5dsjx22pcsf-mainapp-with-plugins-source
error: path '/nix/store/3b7djb5pr87zbscggsr7vnkriw3yp21x-mainapp-go-modules' is not valid
(If you get hash mismatches, just update the flakes with the correct hash; I am not quite sure whether hashing when spreading flakes outside of a repository is reproducible.)
The sources directory (shown by trace) does exist and looks okay. The path given in the error message also exists and contains modules.txt with expected content.
In the folder mainapp, nix build does run successfully, which builds the app without plugins. So what is it that I do with the plugin that makes the path invalid?
The reason is that the file modules.txt generated as part of vendoring will contain the nix store path in the replace directive in this scenario. The vendor directory is a fixed output derivation and thus must not depend on any other derivations. This is violated by the reference in modules.txt.
This can only be fixed by copying the plugin's sources into the sources derivation – that way, the replace path can be relative and thus references no other nix store path.

poetry install | SolverProblemError Because my_project depends on string (*) which doesn't match any versions, version solving failed

I am yet to use poetry to run project, so excuse lack of understanding.
I successfully installed the poetry python library manager, using:
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python3
Next step poetry install initially returned this error:
me#LAPTOP-G1DAPU88:~/.ssh/workers-python/workers$ poetry install
RuntimeError
Poetry could not find a pyproject.toml file in /home/me/.ssh/workers-python/workers or its parents
at ~/.poetry/lib/poetry/_vendor/py3.8/poetry/core/factory.py:369 in locate
365│ if poetry_file.exists():
366│ return poetry_file
367│
368│ else:
→ 369│ raise RuntimeError(
370│ "Poetry could not find a pyproject.toml file in {} or its parents".format(
371│ cwd
372│ )
373│ )
I soon realised I needed my own made pyproject.toml file. Running poetry install again yielded:
$ poetry install
TOMLError
Invalid TOML file /home/me/.ssh/workers-python/workers/pyproject.toml: Key "json " already exists.
at ~/.poetry/lib/poetry/_vendor/py3.8/poetry/core/toml/file.py:34 in read
30│ def read(self): # type: () -> "TOMLDocument"
31│ try:
32│ return super(TOMLFile, self).read()
33│ except (ValueError, TOMLKitError) as e:
→ 34│ raise TOMLError("Invalid TOML file {}: {}".format(self.path.as_posix(), e))
35│
36│ def __getattr__(self, item): # type: (str) -> Any
37│ return getattr(self.__path, item)
38│
Above error indicates there were duplicate entries.
Running poetry install again with the now updated pyproject.toml file in cwd threw this error (in the post's title):
$ poetry install
Creating virtualenv my_project-1_EUeV5I-py3.8 in /home/me/.cache/pypoetry/virtualenvs
Updating dependencies
Resolving dependencies... (28.4s)
SolverProblemError
Because my_project depends on string (*) which doesn't match any versions, version solving failed.
at ~/.poetry/lib/poetry/puzzle/solver.py:241 in _solve
237│ packages = result.packages
238│ except OverrideNeeded as e:
239│ return self.solve_in_compatibility_mode(e.overrides, use_latest=use_latest)
240│ except SolveFailure as e:
→ 241│ raise SolverProblemError(e)
242│
243│ results = dict(
244│ depth_first_search(
245│ PackageNode(self._package, packages), aggregate_package_nodes
However, temporarily removing all instances = "*" gave me this error of \n on line 12... which doesn't appear to be there:
$ poetry install
TOMLError
Invalid TOML file /home/me/.ssh/workers-python/workers/pyproject.toml: Unexpected character: '\n' at line 12 col 5
at ~/.poetry/lib/poetry/_vendor/py3.8/poetry/core/toml/file.py:34 in read
30│ def read(self): # type: () -> "TOMLDocument"
31│ try:
32│ return super(TOMLFile, self).read()
33│ except (ValueError, TOMLKitError) as e:
→ 34│ raise TOMLError("Invalid TOML file {}: {}".format(self.path.as_posix(), e))
35│
36│ def __getattr__(self, item): # type: (str) -> Any
37│ return getattr(self.__path, item)
38│
me#LAPTOP-G1DAPU88:~/.ssh/workers-python/workers$ cat pyproject.toml
[tool.poetry]
name = "my_project"
version = "0.1.0"
description = "Top-level package for my_project."
authors = [""]
packages = [
{ include = "my_project"},
]
[tool.poetry.dependencies]
python = "^3.8"
click # Suspect line
I have reverted this.
Current pyproject.toml:
[tool.poetry]
name = "data_simulator"
version = "0.1.0"
description = "Top-level package for data_simulator."
authors = ["iotahoe <iotahoe#iotahoe.com>"] # daniel.bell#hitachivantara.com / daniel#iotahoe.com
packages = [
{ include = "data_simulator"},
]
[tool.poetry.dependencies]
python = "^3.8"
click = "*"
#logging = "*"
#os = "*"
#pathlib = "*"
#time = "*"
numpy = "*"
pandas = "*"
#json = "*"
#random = "*"
faker = "*"
transformers = "4.4.2"
#re = "*"
#itertools = "*"
#datetime = "*"
#requests = "*"
#copy = "*"
#collections = "*"
#collections.abc = "*"
#multiprocessing = "*"
#multiprocessing.dummy = "*"
nltk = "*"
#nltk.corpus = "*"
#string = "*"
[tool.poetry.dev-dependencies]
isort = "5.6.4"
black = "^20.8b1"
invoke = "^1.4.1"
coveralls = "^2.2.0"
pytest = "^3.0"
flake8 = "^3.8.3"
mypy = "^0.782"
[[tool.poetry.source]]
name = "azure"
url = "https://pkgs.dev.azure.com/iotahoe/Halo/_packaging/private-sources/pypi/simple/"
secondary = true
[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"
Note: 'name', 'authors', 'include', 'url' have been censored.
As a general advise I recommend to use poetry's command line instead of creating/manipulating the pyproject.toml.
Start with a poetry init or poetry init -n and add your dependencies with poetry add.
The problem with your current pyproject.toml is, that you declare built-in packages as dependencies, like os, pathlib, string and others. This is why you receive the message Because my_project depends on string (*) which doesn't match any versions, version solving failed., which means poetry cannot find any matching package information in the repository.
tl;dr: Flush the *.egg-info directories before running poetry lock.
This answer is not strictly related to the current issue, but a similar error message can appear in other circumstances, so I think it's valuable to share it here.
If you are locking in a project where sub-dependencies are directly available on the file system, some *.egg-info directories may interfere with the locking process, causing issues when trying to run poetry install in a context where those *.egg-info files are missing. To avoid the problem: Flush the *.egg-info directories prior to locking. You should then have an updated poetry.lock file with more content.

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"]

cx_Freeze '#rpath/libQtDeclarative.4.dylib': doesn't exist or not a regular file

from cx_Freeze import setup, Executable
# Dependencies are automatically detected, but it might need
# fine tuning.
buildOptions = dict(packages = ["idna","lib","gui","plugins"], excludes = ["Tcl","tcl"]
import sys
base = 'Win32GUI' if sys.platform=='win32' else None
executables = [
Executable('electrum-xvg', base=base, targetName = 'Electrum XVG',icon="electrum.icns")]
setup(name='electrum-xvg',
version = '1.0',
description = '',
options = dict(build_exe = buildOptions),
executables = executables])
I have the above setup.py file which I am using to try build application on OSX Sierra. But when I use python setup.py bdist_mac it raises error
#rpath/libQtDeclarative.4.dylib
error: can't copy '#rpath/libQtDeclarative.4.dylib': doesn't exist or not a regular file
libQtDeclarative.4.dylib is present in ~/anaconda/envs/pyqtapp/lib on my system but when I used otool -D libQtDeclarative.4.dylib it raised error that no such file exists, so I used
install_name_tool -id "#rpath/libQtDeclarative.4.dylib" libQtDeclarative.4.dylib
in ~/anaconda/envs/pyqtapp/lib now when I run otool -D libQtDeclarative.4.dylib I get
libQtDeclarative.4.dylib:
#rpath/libQtDeclarative.4.dylib
but cx_Freeze still raises the error
error: can't copy '#rpath/libQtDeclarative.4.dylib': doesn't exist or not a regular file
Try explicitly setting includes (list of relative paths):
includefiles = ['README.txt', 'CHANGELOG.txt', 'helpers\uncompress\unRAR.exe', , 'helpers\uncompress\unzip.exe']

Resources