I am new to common lisp and want to build a web with RESTAS.
I write a file called api.lisp, it looks like this:
(ql:quickload :restas)
(restas:define-module xxx ) ......
I write some routes, and it works well in Emacs+Slime.
But when i try to load the file in command line, it doesn't work .
Bash>> lx86cl64 -l ~/Git/proj53/src/api/api.lisp
To load "restas":
Load 1 ASDF system:
restas
; Loading "restas"
.
> Error: There is no package named "SWANK" .
> While executing: CCL::%FASL-NVPACKAGE, in process listener(1).
> Type :GO to continue, :POP to abort, :R for a list of available restarts.
> If continued: Retry finding package with name "SWANK".
> Type :? for other options.
1 >
Why i got this error?
Related
I'm trying run guix package install for following manifest:
(specifications->manifest
'("noguix-hugo" ;; A CUSTOM MODULE implemented in /module/root-1/site-lisp/nonguix-hugo.scm
"go"))
The custom module in the manifest is declared as follows:
(define-module (nonguix-hugo)
;; implementation detail
;; ....
)
And the installation command looks like:
guix package --load-path="/module/root1/site-lisp" \
--load-path="/module/root-2/site-lisp" \
--manifest="/path/to/manifest.scm" \
--profile="/path/to/profile"
The command fails with error message:
guix package: error: noguix-hugo: unknown package
However, building the noguix-hugo using guix build command works just fine
guix build --load-path="/module/root1/site-lisp" \
--load-path="/module/root-2/site-lisp" \
nonguix-package
# The command builds and outputs the module location as expected
# /gnu/store/7js349wb17371225njzll9gma8kmwf-nonguix-hugo-1.0
My question:
Why does Guix succeed to locate the module when building it,
but can't seem to locate it when specified in a manifest file.
I even tried adding a (use-modules (nonguix-hugo)) to the manifest and setting GUIX_PACKAGE_PATH as specified in[1], yet the install still fails.
References
[1] https://guix.gnu.org/manual/en/html_node/Package-Modules.html
Okay, turns out this was a typo in the manifest:
(specifications->manifest
'("noguix-hugo"
"go"))
which should be corrected to:
(specifications->manifest
'("nonguix-hugo" ;; <= this line
"go"))
Sheesh!....
I'm running my package through R CMD check and the only (remaining) warning is the following:
W checking for unstated dependencies in 'tests' (4.4s)
'::' or ':::' import not declared from: 'devtools'
After getting confused for a long time about this seemingly nonsensical warning, I realized it's coming from my "test manager" script (see reason for its need below). This is file pkg/tests/testthat.R, while the tests themselves are in pkg/tests/testthat/.
# testthat.R
sink(stderr(), type = "output")
x <- tryCatch(
{
x <- data.frame(devtools::test()) # here's the problem!
as.numeric(sum(x$failed) > 0)
},
error = function(e) {
1
}
)
sink(NULL, type = "output")
cat(1)
If I comment out this entire file, the R CMD check warning vanishes.
And then the weird part: if I replace devtools::test() with just test(), the R CMD check warning vanishes.
However, the purpose of this "manager" script is to be to be called (via Rscript) by a git pre-commit hook. This way, I can run all my tests to ensure the commit is stable. Due to this, I can't use test(), since devtools isn't loaded when the script is run via Rscript.
I tried a few things to satisfy both R CMD check and being called by Rscript:
Using library(devtools) doesn't work (throws a package not found error);
Moving testthat.R out of the /tests/ folder and into the top-level. This kills the R CMD check warning, but it now instead throws a note: Non-standard file/directory found at top level: 'testthat.R', so not exactly satisfactory (especially since keeping it in the /tests/ directory seems more logically consistent);
Testing for a function which has been apparently loaded by R CMD check to determine behavior. Since using a naked test() works, I assumed devtools was loaded, so prepended the following to the file (and used runTests on the problematic line). The logic being, if we can find test(), use it. If we can't, then this probably isn't R CMD check, so we can use the full name.
if (length(find("test")) == 0) {
runTests <- devtools::test()
} else {
runTests <- test()
}
Unfortunately, this just made things worse: the warning remains and we also get an error on the if-else block:
> if (length(find("test")) == 0) {
+ runTests <- devtools::test()
+ } else {
+ runTests <- test()
+ }
Error in loadNamespace(name) : there is no package called 'devtools'
Calls: :: ... loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart
Why devtools::test() throws an error here and just a warning on the problematic line is beyond me.
Similarly, using testthat::skip(). Also doesn't work.
So, what can I do to satisfy both R CMD check and being called by Rscript? Is there a way to tell R CMD check to ignore this file?
For the record, this is my git pre-commit hook, in case it can be reformulated to solve this problem some other way
#!/bin/sh
R_USER="D:/Users/wasabi/Documents"
export R_USER
# check that Rscript is accessible via PATH; fail otherwise
command -v Rscript >/dev/null || {
echo "Rscript must be accessible via PATH. Commit aborted.";
exit 1;
};
# check whether there are unstaged changes. If so, stash them.
# This allows the tests to run only on previously committed or
# indexed (added on this commit) changes.
hasChanges=$(git diff)
if [ -n "$hasChanges" ]; then
git stash push --keep-index
fi
exitCode=$(Rscript tests/testthat.R)
# remember to unstash any unstaged changes
if [ -n "$hasChanges" ]; then
git stash pop
fi
exit $exitCode
The solution is to simply add tests/testthat.R to .Rbuildignore (either by hand in the form of a regular expression or using usethis::use_build_ignore("tests/testthat.R")).
If you actually run R CMD check, the warning will still appear (since it runs on the source files, and therefore ignores .Rbuildignore, unless you run it on the binary itself).
But the "Check Package" command in RStudio relies on devtools::check(), which builds the package first and then checks the binary, therefore not getting the error. And since that's how my team and I will actually be running the checks, it's sufficient.
Solution inspired by this question.
I'm trying to use the solution posted here: https://stackoverflow.com/a/50497981/9355411
and have a .zshrc like:
. $(which env_parallel.zsh)
when I make any call to env_parallel, I get the following error:
env_parallel:92: argument list too long: /usr/bin/parallel
I take it that you run a version < 20180722
and you run it as:
env_parallel echo ::: foo
This will try to copy your full environment (all aliases, all functions, all arrays, and all variables). Unfortunately zsh uses execve to start programs, and execve typically only supports 128 KB of environment.
So what to do? If you upgrade to 20190622 env_parallel will give this error:
env_parallel: Error: Your environment is too big.
env_parallel: Error: You can try 3 different approaches:
env_parallel: Error: 1. Run 'env_parallel --session' before you set
env_parallel: Error: variables or define functions.
env_parallel: Error: 2. Use --env and only mention the names to copy.
env_parallel: Error: 3. Try running this in a clean environment once:
env_parallel: Error: env_parallel --record-env
env_parallel: Error: And then use '--env _'
env_parallel: Error: For details see: man env_parallel
So try one of those suggestions.
--session is supported since 20180522.
I have a weird mix of errors.
I was using CL21, I was in my package, and I wanted to install lparallel. Not possible:
(ql:quickload :lparallel)
To load "lparallel":
Load 1 ASDF system:
lparallel
; Loading "lparallel"
;
; caught ERROR:
; DYNAMIC-EXTENT on a weird thing: (CL21.CORE.FUNCTION:FUNCTION #:BODY-FN1)
;
; compilation unit aborted
; caught 2 fatal ERROR conditions
; caught 1 ERROR condition
; Evaluation aborted on #<UIOP/LISP-BUILD:COMPILE-FILE-ERROR {1008956C13}>.
I can reproduce it in a new session but it's a bit weird: if I quickload lparallel in cl-user, it complains on not finding the symbol CL21.CORE.FUNCTION, even if I didn't do nothing with CL21 yet:
The name "CL21.CORE.FUNCTION" does not designate any package.
So I ql:quickload CL21 and then on retrying to load lparallel. I get the first error.
But, I tried in Portacle for a fresh image and… I couldn't reproduce this.
Any idea ? Is that an issue with cl21, lparallel, quicklisp or asdf??
cl21 seems to replace the standard reader macro #' with its own version that isn't compatible with lparallel. When you tried to load lparallel in a fresh image, ASDF will load it from the .fasl-files that were compiled with cl21 loaded, so you must either delete those files or force recompilation with
(asdf:operate 'asdf:load-op :lparallel :force t)
Loading cl21 after lparallel is compiled with the standard language shouldn't cause the same problem.
Say I have a basic r script:
require(gWidgets2RGtk2)
w<-gbasicdialog("Stage 1.5")
visible(w)
I save it, and attempt to run it with command prompt using a batch file that looks like this:
#echo
"C:\Program Files\R\R-3.0.2\bin\x64\Rscript.exe" "C:\Users\Me\Desktop\test\test.r"
PAUSE
When I attempt to run this script, I get this error after all the packages are loaded:
Error in UseMethod(".gbasicdialog") :
no applicable method for '.gbasicdialog'applied to an object of class "NULL"
Calls: gbasicdialog -> .gbasicdialog
Execution halted
Can anyone see if I am doing anything wrong?
Change the script to this:
options(guiToolkit="RGtk2")
library(gWidgets2)
w <- gbasicdialog("Stage 1.5")
visible(w)
Also I assume you meant #echo off as the first line in the batch file. The PAUSE statement could be omitted.