How to clean error message in Nim? Silence hints? - nim-lang

This erroneous code
import sequtils, sugar, yaml
let a: int
a = ""
produces huge error message
$ nimble run
Verifying dependencies for nim#1
Info: Dependency on yaml#any version already satisfied
Verifying dependencies for yaml#0.14.0
Building nim/app using c backend
Tip: 3 messages have been suppressed, use --verbose to show them.
Error: Build failed for package: nim
... Details:
... Execution failed with exit code 1
... Command: "/usr/local/Cellar/nim/1.2.6/nim/bin/nim" c --noNimblePath -d:NimblePkgVersion=1 --path:"/Users/alex/.nimble/pkgs/yaml-0.14.0" -o:"/alex/projects/alien/old/nim/app" "/alex/projects/alien/old/nim/src/app.nim"
... Output: Hint: used config file '/usr/local/Cellar/nim/1.2.6/nim/config/nim.cfg' [Conf]
... Hint: system [Processing]
... Hint: widestrs [Processing]
... Hint: io [Processing]
... Hint: app [Processing]
... Hint: base [Processing]
... Hint: sequtils [Processing]
... Hint: macros [Processing]
... Hint: sugar [Processing]
... Hint: typetraits [Processing]
... Hint: underscored_calls [Processing]
... Hint: yaml [Processing]
... Hint: dom [Processing]
... Hint: tables [Processing]
... Hint: hashes [Processing]
... Hint: math [Processing]
... Hint: bitops [Processing]
... Hint: algorithm [Processing]
... Hint: streams [Processing]
... Hint: sets [Processing]
... Hint: strutils [Processing]
... Hint: parseutils [Processing]
... Hint: unicode [Processing]
... Hint: stream [Processing]
... Hint: internal [Processing]
... Hint: taglib [Processing]
... Hint: serialization [Processing]
... Hint: times [Processing]
... Hint: options [Processing]
... Hint: posix [Processing]
... Hint: parser [Processing]
... Hint: lex [Processing]
... Hint: lexbase [Processing]
... Hint: presenter [Processing]
... Hint: deques [Processing]
... Hint: hints [Processing]
... Hint: annotations [Processing]
... Hint: tojson [Processing]
... Hint: json [Processing]
... Hint: parsejson [Processing]
... /alex/projects/nim/src/test.nim(3, 5) Error: 'let' symbol requires an initialization
Is it possible to silence the non essential output and have just the error message? Like
... /alex/projects/nim/src/test.nim(3, 5) Error: 'let' symbol requires an initialization

To get that behaviour with the compiler you would use two parameters:
nim c --hints:off --verbosity:0 -r something.nim
Which you could add to a compiler configuration file, and if that's the only thing you need you don't need nimble.
With regards to nimble, from it's changelog it seems the verbosity of commands has changed over time, see if the same compiler parameters work with nimble and if not, create an issue to request such behaviour.

This partially helps nimble --hints:off run

Related

Hiding DeprecationWarning from pytest

I'm writing some tests for code that calls TensorFlow 2.0.1. This library imports the imp module, which triggers a deprecation warning when I run pytest. I'm trying to muffle this warning, but without success.
This is my testing module:
import pytest
import warnings
from fclib.models.dilated_cnn import create_dcnn_model
def test_create_dcnn_model():
with pytest.deprecated_call():
create_dcnn_model(seq_len=1, max_cat_id=[30, 120]) # calls tensorflow.keras code
The output from pytest test_dcnn.py is
[...]
======================================== FAILURES ========================================
_________________________________ test_create_dcnn_model _________________________________
def test_create_dcnn_model():
with pytest.deprecated_call():
> create_dcnn_model(seq_len=1, max_cat_id=[30, 120])
E Failed: DID NOT WARN. No warnings of type (<class 'DeprecationWarning'>, <class 'PendingDeprecationWarning'>) was emitted. The list of emitted warnings is: [].
fclib/tests/test_dcnn.py:11: Failed
---------------------------------- Captured stderr call ----------------------------------
2020-07-07 03:15:03.162833: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 AVX512F FMA
2020-07-07 03:15:03.174538: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 2095190000 Hz
2020-07-07 03:15:03.177318: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x55ef3370ff20 executing computations on platform Host. Devices:
2020-07-07 03:15:03.177351: I tensorflow/compiler/xla/service/service.cc:175] StreamExecutor device (0): Host, Default Version
==================================== warnings summary ====================================
/data/anaconda3/envs/forecasting_env/lib/python3.6/site-packages/tensorflow_core/python/pywrap_tensorflow_internal.py:15
/data/anaconda3/envs/forecasting_env/lib/python3.6/site-packages/tensorflow_core/python/pywrap_tensorflow_internal.py:15: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
import imp
-- Docs: https://docs.pytest.org/en/latest/warnings.html
================================ short test summary info =================================
FAILED fclib/tests/test_dcnn.py::test_create_dcnn_model - Failed: DID NOT WARN. No warn...
============================== 1 failed, 1 warning in 2.39s ==============================
So it complains that there was no warning, and yet the printed output says that there was a warning. What's happening here?
If I remove the with pytest.deprecated_call() line, I get:
def test_create_dcnn_model():
# with pytest.deprecated_call():
create_dcnn_model(seq_len=1, max_cat_id=[30, 120])
================================== test session starts ===================================
platform linux -- Python 3.6.10, pytest-5.4.3, py-1.9.0, pluggy-0.13.1
rootdir: /data/forecasting/fclib
collected 1 item
fclib/tests/test_dcnn.py . [100%]
==================================== warnings summary ====================================
/data/anaconda3/envs/forecasting_env/lib/python3.6/site-packages/tensorflow_core/python/pywrap_tensorflow_internal.py:15
/data/anaconda3/envs/forecasting_env/lib/python3.6/site-packages/tensorflow_core/python/pywrap_tensorflow_internal.py:15: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
import imp
-- Docs: https://docs.pytest.org/en/latest/warnings.html
============================== 1 passed, 1 warning in 2.00s ==============================
So it passes, but the warning message is still present. How can I get rid of that message completely?

How can i make the busybox1.23.2 Compile success?

package: busybox
version: 1.23.2
when i make busybox , it produces unexpected results.
the crosschaintool i use is ARM/uClinux Toolchain arm-2010q1-189-arm- uclinuxeabi-i686-pc-linux-gnu,but i can't make the busybox,like this:
root#ubuntu:/busybox/busybox-1.23.2# make
SPLIT include/autoconf.h -> include/config/*
GEN include/bbconfigopts.h
HOSTCC applets/usage
applets/usage.c: In function ‘main’:
applets/usage.c:52:3: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
write(STDOUT_FILENO, usage_array[i].usage, strlen(usage_array[i].usage) + 1);
^
GEN include/usage_compressed.h
HOSTCC applets/applet_tables
applets/applet_tables.c: In function ‘main’:
applets/applet_tables.c:161:4: warning: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Wunused-result]
fgets(line_old, sizeof(line_old), fp);
^
GEN include/applet_tables.h
CC applets/applets.o
LD applets/built-in.o
HOSTCC applets/usage_pod
applets/usage_pod.c: In function ‘main’:
applets/usage_pod.c:74:3: warning: format not a string literal and no format arguments [-Wformat-security]
printf(usage_array[i].aname);
^
CC libbb/appletlib.o
CC libbb/vfork_daemon_rexec.o
AR libbb/lib.a
CC shell/hush.o
shell/hush.c: In function 'builtin_source':
shell/hush.c:8901: warning: 'sv.sv_g_malloced' may be used uninitialized in this function
shell/hush.c:8901: warning: 'sv.sv_g_argc' may be used uninitialized in this function
shell/hush.c:8901: warning: 'sv.sv_g_argv' may be used uninitialized in this function
shell/hush.c:8901: warning: 'sv.sv_argv0' may be used uninitialized in this function
AR shell/lib.a
LINK busybox_unstripped
Trying libraries: crypt m
Library crypt is not needed, excluding it
Library m is not needed, excluding it
Final link with: <none>
arm-uclinuxeabi-strip:busybox_unstripped: File format not recognized
Makefile:723: recipe for target 'busybox' failed
make: *** [busybox] Error 1
how should i do? is the busybox can't use the ARM/uClinux Toolchain? how should i do ?we'll really appreciate it if you can give us some advice and some pieces of guidance,thanks!
LINK busybox_unstripped Trying libraries: crypt m Library crypt
is not needed, excluding it Library m is not needed, excluding it
Final link with: arm-uclinuxeabi-strip:busybox_unstripped: File
format not recognized Makefile:723: recipe for target 'busybox' failed
make: *** [busybox] Error 1
As there is only a piece of the whole compiling log, some suggestions are:
1) Please check the compiling log from the beginning whether there are other important warnings or errors.
2) busybox_unstripped file is generated or not? Check the makefile dependencies to find out whether all dependencies files are successfully generated. From the log, some libraries are excluded so that you may have to check the busybox configuration file.
3) If busybox_unstripped file is generated, check the makefile about the link grammar of "Final link with:". For the cross-tool chain to link successfully, please make sure the link command is correct.
Good luck!

GHC RTS runtime errors when using hs_init with profiling of shared cabal library

I have a large C project which must be compiled with gcc. So I link the main executable with a file like this:
#include <HsFFI.h>
static void my_enter(void) __attribute__((constructor));
static void my_enter(void) {
static char *argv[] = { "Pointer.exe", 0 };
//static char *argv[] = { "Pointer.exe", "+RTS", "-N", "-p", "-s", "-h", "-i0.1", "-RTS", 0 };
static char **argv_ = argv;
static int argc = 1; // 8 for profiling
hs_init(&argc, &argv_);
//hs_init_with_rtsopts(&argc, &argv_);
}
static void my_exit(void) __attribute__((destructor));
static void my_exit(void) { hs_exit(); }
which works as expected - the GHC runtime system gets initialized and I'm able to use the FFI to call Haskell code from C.
I then attempt to enable profiling (mainly for stack traces with Debug.Trace) and code coverage (HPC) using the "+RTS", "-N", "-p", "-s", "-h", "-i0.1", "-RTS" flags on the line commented out above. However I get error messages about threading and profiling during initialization:
Pointer.exe: the flag -N requires the program to be built with -threaded
Pointer.exe: the flag -p requires the program to be built with -prof
Pointer.exe: Most RTS options are disabled. Use hs_init_with_rtsopts() to enable them.
Pointer.exe: newBoundTask: RTS is not initialised; call hs_init() first
I configured the cabal package with:
"--enable-library-profiling"
"--enable-executable-profiling"
"--enable-shared"
"--enable-tests"
"--enable-coverage"
which has properly given me stack traces and code coverage when running executables compiled as part of the cabal project.
If I try to use hs_init_with_rtsopts as recommended by the error message, I get a SIGSEGV during the GHC rts initialization:
Using host libthread_db library "/usr/lib/libthread_db.so.1".
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff6a2d0ca in strlen () from /usr/lib/libc.so.6
(gdb) bt
#0 0x00007ffff6a2d0ca in strlen () from /usr/lib/libc.so.6
#1 0x00007ffff798c5f6 in copyArg (
arg=0x657372615062696c <error: Cannot access memory at address 0x657372615062696c>) at rts/RtsFlags.c:1684
#2 0x00007ffff798c679 in copyArgv (argc=8, argv=0x555555554cee) at rts/RtsFlags.c:1696
#3 0x00007ffff798dbe2 in setFullProgArgv (argc=<optimized out>, argv=<optimized out>) at rts/RtsFlags.c:1780
#4 0x00007ffff798e773 in hs_init_ghc (argc=0x555555756090 <argc>, argv=0x5555557560a0 <argv>, rts_config=...)
at rts/RtsStartup.c:162
#5 0x00007ffff798e7cc in hs_init_with_rtsopts (argc=<optimized out>, argv=<optimized out>)
at rts/RtsStartup.c:121
#6 0x0000555555554c7d in __libc_csu_init ()
#7 0x00007ffff69cc59f in __libc_start_main () from /usr/lib/libc.so.6
#8 0x0000555555554b29 in _start ()
So how can I enable runtime profiling from a program compiled with gcc?
So the segfault was due to a typo which was not included in the question. Sneaky!
To enable threading and profiling and so on you must link your final program against the appropriate RTS flavor. This is one effect of GHC's -prof flag, and the only effect of its -threaded flag, and various other flags like -debug.
The RTS flavors are in different libraries with names of the form
libHSrts.a libHSrts-ghc7.8.4.so (vanilla)
libHSrts_debug.a libHSrts_debug-ghc7.8.4.so (debug)
libHSrts_thr.a libHSrts_thr-ghc7.8.4.so (threaded)
libHSrts_p.a - (profiling)
libHSrts_thr_p.a - (threaded+profiling)
libHSrts_l.a libHSrts_l-ghc7.8.4.so (eventlog)
...
On the left are static libraries; on the right are dynamic libraries, whose library names include the GHC version to make it easier for the runtime dynamic loader to find the correct version if you have multiple versions of GHC installed. You can see the full list for your GHC installation under "RTS ways" in ghc --info.
There are no dynamic profiling libraries installed by default but I think there is no fundamental problem with having them and you can configure the GHC build system to build them. (They are not especially useful now because ghci does not support profiling, though that is hopefully changing very soon.)

Protoc error in Windows

I'm trying to compile protocol buffers code using the maven protoc plugin and a protoc executable that I built inside Cygwin. I can't do this from Cygwin or from the Windows command line. Below is the output that I get when I run it in Windows, but the error is identical when running from Cygwin. I find this strange because if the issue was with path translation then I'd expect one of them to work. Is it possible that the fact that the executable was built with Cygwin's g++ could affect things? (To state the obvious, the directory in question does exist.)
Edit: I get the same error when I take maven out of the picture and just invoke protoc by hand.
Edit 2: I can fix this by invoking protoc by hand from Cygwin using relative or absolute paths (but tilde-expansion does not work). Invoking protoc by hand from Windows using relative or absolute paths continues to give the same error.
[DEBUG] (f) outputDirectory = c:\cygwin64\home\dan\code\server\protocol\target\generated-sources\protobuf\java
[DEBUG] (f) project = MavenProject: server:protocol:1.0-SNAPSHOT # c:\cygwin64\home\dan\code\server\protocol\pom.xml
[DEBUG] (f) protoSourceRoot = c:\cygwin64\home\dan\code\server\protocol\src\main\proto
[DEBUG] (f) protocPluginDirectory = c:\cygwin64\home\dan\code\server\protocol\target\protoc-plugins
[DEBUG] (f) remoteRepositories = [
id: central
url: https://repo.maven.apache.org/maven2
layout: default snapshots: [enabled => false, update => daily]
releases: [enabled => true, update => daily]
]
[DEBUG] (f) session = org.apache.maven.execution.MavenSession#24fb6a80
[DEBUG] (f) skip = false
[DEBUG] (f) staleMillis = 0
[DEBUG] (f) temporaryProtoFileDirectory = c:\cygwin64\home\dan\code\server\protocol\target\protoc-dependencies
[DEBUG] (f) writeDescriptorSet = false
[DEBUG] -- end configuration --
[WARNING] No 'protocExecutable' parameter is configured, using the default: 'protoc'
[DEBUG] Proto source root:
[DEBUG] c:\cygwin64\home\dan\code\server\protocol\src\main\proto
[DEBUG] [PROTOC] Executable:
[DEBUG] [PROTOC] protoc
[DEBUG] [PROTOC] Protobuf import paths:
[DEBUG] [PROTOC] c:\cygwin64\home\dan\code\server\protocol\src\main\proto [DEBUG] [PROTOC] Java output directory:
[DEBUG] [PROTOC] c:\cygwin64\home\dan\code\server\protocol\target\generated-sources\protobuf\java
[DEBUG] [PROTOC] Protobuf descriptors:
[DEBUG] [PROTOC] c:\cygwin64\home\dan\code\server\protocol\src\main\proto\message.proto
[DEBUG] [PROTOC] Command line options:
[DEBUG] [PROTOC]
--proto_path=c:\cygwin64\home\dan\code\server\protocol\src\main\proto
--java_out=c:\cygwin64\home\dan\code\server\protocol\target\generated-sources\protobuf\java
c:\cygwin64\home\dan\code\server\protocol\src\main\proto\message.proto
[INFO] Compiling 1 proto file(s) to c:\cygwin64\home\dan\code\server\protocol\target\generated-sources\protobuf\java
[ERROR] PROTOC FAILED: c: warning: directory does not exist. c:\cygwin64\home\dan\code\server\protocol\src\main\proto\message.proto: File does not reside within any path specified using --proto_path (or -I). You must specify a --proto_path which encompasses this file. Note that the proto_path must be an exact prefix of the .proto file names -- protoc is too dumb to figure out when two paths (e.g. absolute and relative) are equivalent (it's harder than you think).
Executables that you build using Cygwin will depend on the full Cygwin environment and will behave as Cygwin programs, regardless of how you execute them. That is, if you execute a Cygwin program from the non-Cygwin shell, it will still behave as a Cygwin program. Cygwin programs do not accept Windows-style paths that use backslashes an drive letters; you need to use e.g. /cygdrive/c/ instead of c:\.
In general, you should not attempt to use Cygwin-compiled command-line tools from a non-Cygwin shell. Instead, try building protoc using MSVC or MinGW, or use the pre-built Windows binaries that Google provides.

what is the goal and output of process in Scratch.hs and running example such as BasicSpec.casl got error with Scratch

update1
i have to cabal install maude in order to use rewrite, if not import maude, how can het tools's haskell code use rewrite and reduce in its haskell code?
how to prove the logic with algebraic spec input file or default system
and logic string as parameters to return output into console ? is there examples for this and do all these in Scratch?
Moreover would like to read Owl file in Scratch and do inference in Scratch, is there example for this?
https://github.com/spechub/Hets/blob/master/Scratch.hs
update2
succeed to run first example RelationAndOrders.casl, however, what is the goal and output of process in Scratch.hs
martin#ubuntu:~/Downloads/Hets-master$ sudo cp Scratch /usr/lib/hets/hets-lib/Basic/Scratch
martin#ubuntu:~/Downloads/Hets-master$ cd /usr/lib/hets/hets-lib/Basic
martin#ubuntu:/usr/lib/hets/hets-lib/Basic$ ./Scratch RelationsAndOrders.casl
### file name 'RelationsAndOrders.casl' does not match library name 'Basic/RelationsAndOrders'
Analyzing library Basic/RelationsAndOrders version 1.0
Downloading Basic/Numbers ...
Analyzing library Basic/Numbers version 1.0
Analyzing spec Basic/Numbers?Nat
Analyzing spec Basic/Numbers?Int
Analyzing spec Basic/Numbers?Rat
Analyzing spec Basic/Numbers?DecimalFraction
... loaded Basic/Numbers
Analyzing spec Basic/RelationsAndOrders?Relation
Analyzing spec Basic/RelationsAndOrders?ReflexiveRelation
Analyzing spec Basic/RelationsAndOrders?IrreflexiveRelation
Analyzing spec Basic/RelationsAndOrders?SymmetricRelation
Analyzing spec Basic/RelationsAndOrders?AsymmetricRelation
Analyzing spec Basic/RelationsAndOrders?AntisymmetricRelation
Analyzing spec Basic/RelationsAndOrders?TransitiveRelation
Analyzing spec Basic/RelationsAndOrders?SimilarityRelation
Analyzing spec Basic/RelationsAndOrders?PartialEquivalenceRelation
Analyzing spec Basic/RelationsAndOrders?EquivalenceRelation
Analyzing spec Basic/RelationsAndOrders?PreOrder
Analyzing spec Basic/RelationsAndOrders?StrictOrder
Analyzing spec Basic/RelationsAndOrders?PartialOrder
Analyzing spec Basic/RelationsAndOrders?TotalOrder
Analyzing spec Basic/RelationsAndOrders?StrictTotalOrder
Analyzing spec Basic/RelationsAndOrders?RightUniqueRelation
Analyzing spec Basic/RelationsAndOrders?LeftTotalRelation
Analyzing spec Basic/RelationsAndOrders?BooleanAlgebra
Analyzing spec Basic/RelationsAndOrders?ExtPartialOrder
Analyzing spec Basic/RelationsAndOrders?ExtTotalOrder
Analyzing spec Basic/RelationsAndOrders?ExtBooleanAlgebra
Analyzing spec Basic/RelationsAndOrders?RichPartialOrder
Analyzing spec Basic/RelationsAndOrders?RichTotalOrder
Analyzing spec Basic/RelationsAndOrders?RichBooleanAlgebra
Analyzing view Basic/RelationsAndOrders?TotalOrder_in_Nat
Analyzing view Basic/RelationsAndOrders?TotalOrder_in_Int
Analyzing view Basic/RelationsAndOrders?TotalOrder_in_Rat
Analyzing view Basic/RelationsAndOrders?PartialOrder_in_ExtBooleanAlgebra
update3
when running BasicSpec.casl
martin#ubuntu:~/Downloads/Hets-master/CASL/test$ ./Scratch BasicSpec.casl
Analyzing file BasicSpec.casl as library BasicSpec
Analyzing spec BasicSpec?BasicSpec
unexpected mixfix token: 252
/home/martin/Downloads/Hets-master/CASL/test/BasicSpec.casl:710.31:
*** Error:
missing %number annotation
/home/martin/Downloads/Hets-master/CASL/test/BasicSpec.casl:710.31:
*** Error:
unexpected mixfix token: 253
/home/martin/Downloads/Hets-master/CASL/test/BasicSpec.casl:711.31:
*** Error:
missing %number annotation
/home/martin/Downloads/Hets-master/CASL/test/BasicSpec.casl:711.31:
*** Error:
unexpected mixfix token: 254
/home/martin/Downloads/Hets-master/CASL/test/BasicSpec.casl:712.31:
*** Error:
missing %number annotation
/home/martin/Downloads/Hets-master/CASL/test/BasicSpec.casl:712.31:
*** Error:
unexpected mixfix token: 255
Scratch: user error (Stopped due to errors)

Resources