In Meteor: How to use a npm library that should be pulled from a repository? - node.js

In my packages.json file, I have:
{
"sendwithus":"git+https://git#github.com/whalepath/sendwithus_nodejs.git#enable_testing_server"
}
because I need to use a forked ( and fixed version of the library). The above syntax works in straight node. How to do this in meteor?
This is the error I get:
=> Started proxy.
=> Errors prevented startup:
While reading package from `src/packages/npm-container`:
package.js:14:7: must declare exact version of dependency:
sendwithus#git+https://git#github.com/whalepath/sendwithus_nodejs.git#enable_testing_server
Update:
I tried removing the line and using meteor add to get the package included:
Failed:
meteor add sendwithus#2.9.1#https://github.com/whalepath/sendwithus_nodejs/commit/41b0d177f6eabf02de2daec9bb2b36daebbfbef4
=> Errors while parsing arguments:
While adding package sendwithus#2.9.1#https://github.com/whalepath/sendwithus_nodejs/commit/41b0d177f6eabf02de2daec9bb2b36daebbfbef4:
error: Package names can only contain lowercase ASCII alphanumerics, dash, dot, or colon, not "#".
Failed:
$ meteor add sendwithus#2.9.1_https://github.com/whalepath/sendwithus_nodejs/commit/41b0d177f6eabf02de2daec9bb2b36daebbfbef4
=> Errors while parsing arguments:
While adding package sendwithus#2.9.1_https://github.com/whalepath/sendwithus_nodejs/commit/41b0d177f6eabf02de2daec9bb2b36daebbfbef4:
error: Can't have two _ in version: 2.9.1_https://github.com/whalepath/sendwithus_nodejs/commit/41b0d177f6eabf02de2daec9bb2b36daebbfbef4
Failed:
$ meteor add server:sendwithus#2.9.1#https://github.com/whalepath/sendwithus_nodejs/commit/41b0d177f6eabf02de2daec9bb2b36daebbfbef4
=> Errors while parsing arguments:
While adding package server:sendwithus#2.9.1#https://github.com/whalepath/sendwithus_nodejs/commit/41b0d177f6eabf02de2daec9bb2b36daebbfbef4:
error: Package names can only contain lowercase ASCII alphanumerics, dash, dot, or colon, not "#".
Failed:
$ meteor add sendwithus#https://github.com/whalepath/sendwithusnodejs/commit/41b0d177f6eabf02de2daec9bb2b36daebbfbef4
=> Errors while parsing arguments:
While adding package sendwithus#https://github.com/whalepath/sendwithusnodejs/commit/41b0d177f6eabf02de2daec9bb2b36daebbfbef4:
error: Version string must look like semver (eg '1.2.3'), not 'https://github.com/whalepath/sendwithusnodejs/commit/41b0d177f6eabf02de2daec9bb2b36daebbfbef4'.

Based on the answer to this issue when I posted it to enter link description here, the only solution is to create a fake meteor package to wrap the new node library.
Npm.depends({sendwithus: "https://github.com/whalepath/sendwithusnodejs/commit/41b0d177f6eabf02de2daec9bb2b36daebbfbef4"});
To extend this answer:
Just to use a fork of a npm library requires:
packages/sendwithus/main.js:
SendWithUs = Npm.require('sendwithus');
2.
packages/sendwithus/package.js:
Package.describe({
summary: 'Wrapped sendwithus library',
version: '2.9.1',
name: 'sendwithus'
});
Npm.depends({sendwithus: "https://github.com/whalepath/sendwithus_nodejs/tarball/41b0d177f6eabf02de2daec9bb2b36daebbfbef4"});
Package.onUse(function(api){
api.addFiles('main.js', 'server');
api.export('SendWithUs');
});
removing the reference in the packages.json
meteor add sendwithus
Using the SendWithUs variable
Maybe this could be improved?

Related

Error: package or namespace load failed for ‘glmmTMB’

I am trying to use package glmmTMB. When I call library(glmmTMB) this is the error message:
">library(glmmTMB)
Error: package or namespace load failed for ‘glmmTMB’ in inDL(x, as.logical(local), as.logical(now), ...):
function 'Rcpp_precious_remove' not provided by package 'Rcpp'
In addition: Warning messages:
1: package ‘glmmTMB’ was built under R version 4.0.5
2: In checkMatrixPackageVersion() :
Package version inconsistency detected.
TMB was built with Matrix version 1.3.4
Current Matrix version is 1.2.18
Please re-install 'TMB' from source using install.packages('TMB', type = 'source') or ask CRAN for a binary version of 'TMB' matching CRAN's 'Matrix' package
I have tried using install.packages('TMB', type = 'source') with no luck. Any ideas?
It's a FAQ -- search for 'Rcpp_precious_remove' not provided by package 'Rcpp'.
In short you are mixing a NEWER compilatio nof something that was built with Rcpp 1.0.7 present with an older installed version which lacks the symbol.
Fix: install.packages("Rcpp") to get the newer Rcpp. And I generally recommend regular update.packages() runs to avoid these issues.

Haskell dependency hell

I'm trying to include a specific version of a library in a Haskell project. The library is bed-and-breakfast (which is used for martix operations), but I need the specific version 0.4.3 which fixed a bug with the multiplication implementation.
So, my stack.yaml looks like this:
flags: {}
extra-package-dbs: []
packages:
- .
extra-deps:
- bed-and-breakfast-0.4
- base-4.6.0.1
resolver: lts-12.8
But I'm getting this error when building:
Error: While constructing the build plan, the following exceptions were encountered:
In the dependencies for bed-and-breakfast-0.4:
base-4.11.1.0 from stack configuration does not match >=4.5 && <4.7 (latest matching version
is 4.6.0.1)
needed due to realworldhaskell-0.1.0.0 -> bed-and-breakfast-0.4
Some different approaches to resolving this:
* Set 'allow-newer: true' to ignore all version constraints and build anyway.
* Consider trying 'stack solver', which uses the cabal-install solver to attempt to find some
working build configuration. This can be convenient when dealing with many complicated
constraint errors, but results may be unpredictable.
* Recommended action: try adding the following to your extra-deps
in C:\Users\info\Desktop\Projects\haskell\stack.yaml:
- base-4.6.0.1
I've done the recommended action but it didn't solve anything. I've tried using different resolvers to see if it's an issue with my GHCi version but nothings worked. What is the best way to interpret error messages like this and how should I proceed?
EDIT:
If I remove -base.4.6.0.1 and add allow-newer: true I get this:
WARNING: Ignoring out of range dependency (allow-newer enabled): base-4.11.1.0. bed-and-breakfast requires: >=4.5 && <4.7
bed-and-breakfast-0.4: configure
Progress 1/2
-- While building custom Setup.hs for package bed-and-breakfast-0.4 using:
C:\sr\setup-exe-cache\x86_64-windows\Cabal-simple_Z6RU0evB_2.2.0.1_ghc-8.4.3.exe --builddir=.stack-work\dist\7d103d30 configure --with-ghc=C:\Users\info\AppData\Local\Programs\stack\x86_64-windows\ghc-8.4.3\bin\ghc.EXE --with-g
hc-pkg=C:\Users\info\AppData\Local\Programs\stack\x86_64-windows\ghc-8.4.3\bin\ghc-pkg.EXE --user --package-db=clear --package-db=global --package-db=C:\sr\snapshots\76fd1958\pkgdb --package-db=C:\Users\info\Desktop\Projects\haskell\
.stack-work\install\8c390635\pkgdb --libdir=C:\Users\info\Desktop\Projects\haskell\.stack-work\install\8c390635\lib --bindir=C:\Users\info\Desktop\Projects\haskell\.stack-work\install\8c390635\bin --datadir=C:\Users\info\Desktop\Proj
ects\haskell\.stack-work\install\8c390635\share --libexecdir=C:\Users\info\Desktop\Projects\haskell\.stack-work\install\8c390635\libexec --sysconfdir=C:\Users\info\Desktop\Projects\haskell\.stack-work\install\8c390635\etc --docdir=C:
\Users\info\Desktop\Projects\haskell\.stack-work\install\8c390635\doc\bed-and-breakfast-0.4 --htmldir=C:\Users\info\Desktop\Projects\haskell\.stack-work\install\8c390635\doc\bed-and-breakfast-0.4 --haddockdir=C:\Users\info\Desktop\Pr
ojects\haskell\.stack-work\install\8c390635\doc\bed-and-breakfast-0.4 --dependency=array=array-0.5.2.0 --dependency=base=base-4.11.1.0 --dependency=binary=binary-0.8.5.1 --dependency=deepseq=deepseq-1.4.3.0 --dependency=template-hask
ell=template-haskell-2.13.0.0 --extra-include-dirs=C:\Users\info\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include --extra-lib-dirs=C:\Users\info\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\min
gw64\bin --extra-lib-dirs=C:\Users\info\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\lib --exact-configuration
Process exited with code: ExitFailure 1
Logs have been written to: C:\Users\info\Desktop\Projects\haskell\.stack-work\logs\bed-and-breakfast-0.4.log
Configuring bed-and-breakfast-0.4...
Cabal-simple_Z6RU0evB_2.2.0.1_ghc-8.4.3.exe: The package has an impossible
version range for a dependency on an internal library: bed-and-breakfast
==0.3.2. This version range does not include the current package, and must be
removed as the current package's library will always be used.
EDIT 2:
Ok, so I'm guessing that the bed-and-breakfast library needs base 4.11.1.0 which is included in GHCi 6.10.2 (according to https://wiki.haskell.org/Base_package) so I need a resolver which matches that GHCi version. Where can I find out what resolver version that is?
Here is the constraint on the latest available bed-and-breakfast package: base (>=4.5 && <4.7), which means it will likely not even compile with GHC version higher then 7.6. Considering that there is even no LTS snapshot prior to GHC 7.8, you are out of luck with that package.
To say it in another words, the package is outdated and your choices are:
submit an issue and hope maintainer will do something about it
try to make it work with newer ghc yourself
Use a different package

Package Node-Red using zeit/pkg

I am having some issues using zeit/pkg on my node-red project. Here are the steps to replicate the issue:
git clone https://github.com/node-red/node-red.git
cd node-red
npm install
npm run build
After build command I added the following to my package.json file:
"pkg": {
"assets": [
"./red/**/*"
],
"scripts": [
"./red/**/*.js"
]
}
Run the command pkg .
After running pkg . I get the following errors:
C:\xampp\htdocs\node-red>pkg .
> pkg#4.3.4
> Targets not specified. Assuming:
node8-linux-x64, node8-macos-x64, node8-win-x64
> Warning Cannot resolve 'path.join(__dirname, '..', '..', 'package.json')'
C:\xampp\htdocs\node-red\red\runtime\index.js
Dynamic require may fail at run time, because the requested file
is unknown at compilation time and not included into executable.
Use a string literal as an argument for 'require', or leave it
as is and specify the resolved file name in 'scripts' option.
> Warning Cannot resolve ''./' + aSettings.storageModule'
C:\xampp\htdocs\node-red\red\runtime\storage\index.js
Dynamic require may fail at run time, because the requested file
is unknown at compilation time and not included into executable.
Use a string literal as an argument for 'require', or leave it
as is and specify the resolved file name in 'scripts' option.
> Warning Cannot resolve 'relPath'
C:\xampp\htdocs\node-red\red\runtime\nodes\registry\loader.js
Dynamic require may fail at run time, because the requested file
is unknown at compilation time and not included into executable.
Use a string literal as an argument for 'require', or leave it
as is and specify the resolved file name in 'scripts' option.
Running the exe after the pkg command gives me this error:
Node-RED has not been built. See README.md for details
Any help would be greatly appreciated. It seems like a simple path issue but I can't seem to get it working.

Installing a package outside current resolver

I'm using stack lts-9.0 snapshot, which includes process-1.4.X. Due to some problems with this version, I would like to use process-1.6.1.0. Adding this version to extra-deps does not seem to be enough:
extra-deps:
- process-1.6.1.0
since this will cause the following error:
Error: While constructing the build plan, the following exceptions were encountered:
In the dependencies for Cabal-1.24.2.0:
process-1.6.1.0 must match >=1.1.0.1 && <1.5 (latest applicable is 1.4.3.0)
What do I need to do in these cases?
As written in the message, the problem is with Cabal-1.24.2.0 depending on process < 1.5.
Add Cabal-2.0.0.2 to the extra-deps.

Why am I getting build plan errors running "stack haddock" when "stack test" works?

I'm creating a new Haskell project using Stack 0.1.3.1 on Windows 8. My stack.yaml file looks like this:
flags: {}
packages:
- 'lazy-engine'
extra-deps: []
resolver: lts-3.4
When I run stack build or stack test, everything works beautifully. I can run haddock manually from the command line and that works, too. But when I run stack haddock I get output like this:
Setting codepage to UTF-8 (65001) to ensure correct output from GHC
NOTE: the haddock command is functionally equivalent to 'build --haddock'
While constructing the BuildPlan the following exceptions were encountered:
-- Failure when adding dependencies:
base: needed (>=4.5 && <4.9), latest is 4.8.1.0, but not present in build plan
needed for package: array-0.5.1.0
-- While attempting to add dependency,
Could not find package base in known packages
-- Failure when adding dependencies:
array: needed (-any), latest is 0.5.1.0, but couldn't resolve its dependencies
base: needed (>=4.2 && <5), latest is 4.8.1.0, but not present in build plan
deepseq: needed (>=1.2 && <1.5), latest is 1.4.1.2, but couldn't resolve its dependencies
ghc-prim: needed (-any), latest is 0.4.0.0, but not present in build plan
needed for package: containers-0.5.6.2
-- Failure when adding dependencies:
array: needed (>=0.3 && <0.6), latest is 0.5.1.0, but couldn't resolve its dependencies
base: needed (==4.3.* || >=4.5 && <4.9), latest is 4.8.1.0, but not present in build plan
needed for package: deepseq-1.4.1.1
-- While attempting to add dependency,
Could not find package ghc-prim in known packages
-- Failure when adding dependencies:
base: needed (>=4.7 && <5), latest is 4.8.1.0, but not present in build plan
containers: needed (==0.5.*), latest is 0.5.6.3, but couldn't resolve its dependencies
needed for package: lazy-engine-0.1.0.0
Recommended action: try adding the following to your extra-deps in
C:\Users\Aaron\Documents\GitHub\lazy-engine\stack.yaml
- base-4.8.1.0
- ghc-prim-0.4.0.0
You may also want to try the 'stack solver' command
Obviously this is nonsense—I shouldn't have to add base to my extra-deps, especially since I'm working off an LTS package set! What is going on here?
Update: As discussed in the answer below, this seems to have been a bug in stack and should be fixed in newer versions. See https://github.com/fpco/minghc/issues/85.
A guess: you're using a GHC install that does not include documentation, or at least not as stack expects it to be discovered. Can you try with "--install-ghc --no-system-ghc"? I may have the specific flag names wrong.
Also, how is GHC installed on your system?
I solved this by installing the ghc-doc package (available in most package managers).

Resources