How to run an EXE file compiled from a F# source on the Mac Terminal? - command-line

I have a hello world program in F#.
open System
[<EntryPoint>]
let main argv =
printfn "Hello World from F#!"
0 // return an integer exit code%
On an Mac OS, I can compile it with "fsharpc", which generates two files
FSharp.Core.dll hello.exe
The EXE file certainly looks strange on a Mac. But how can I execute it from the command line, without using a project structure (because it seems an overkill) like what is explained here: https://dotnet.microsoft.com/learn/languages/fsharp-hello-world-tutorial/create
Actually if I run "dotnet hello.exe", I get this error:
A fatal error was encountered. The library 'libhostpolicy.dylib'
required to execute the application was not found in
'/Users/zell/hello/'. Failed to run as a self-contained app. If this
should be a framework-dependent app, add the
/Users/zell/hello/hello.runtimeconfig.json file specifying the
appropriate framework.

You can create and build/run F# apps like so:
dotnet new console -lang F# -o SomeDirectory && cd SomeDirectory
dotnet run
Building it without running is:
dotnet build
You can see a reference for all commands here: https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet
You appear to have Mono installed, which is where fsharpc comes from. I wouldn't recommend using that unless you are doing mobile development with Xamarin, which currently requires Mono.

By trial and error, I found to run my new .exe file, I needed a .runtimeconfig.json file in the same folder with same without-the-extension-name, i.e. hello.runtimeconfig.json:
{
"runtimeOptions": {
"tfm": "net5.0",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "5.0.0"
}
}
}
Then dotnet hello.exe will work.

Related

Parse csproj file using cake's ParseProject

Create minimal repro project:
dotnet new classlib --no-restore --output /tmp/Foo
cd /tmp/Foo
dotnet new tool-manifest
dotnet tool install cake.tool
touch build.cake
Put this minimal script in build.cake:
Task("Default").Does(() => {
var file = "./Foo.csproj";
Information(FileExists(file).ToString());
var props = ParseProject(file);
});
RunTarget("Default");
Run it:
dotnet cake
Result:
========================================
Default
========================================
True
An error occurred when executing task 'Default'.
Error: Failed to parse project properties
Surely this minimal script should succeed - have I made a mistake, or is this a bug?
My environment: linux, dotnet 6.0.302.
Out of box, the ParseProject alias within Cake (version 2.2.0), only knows how to parse Visual Studio Project files that are using the "old" format.
Since the Visual Studio Project file that you are creating is using the "new" format (i.e. it was generated using the dotnet CLI, and is targetting .NET Core), the ParseProject in Cake will not be able to recognise it.
There is however an alternative ParseProject alias in the Cake.Incubator addin that can do what you want. You can make use of this by doing:
#addin nuget:?package=Cake.Incubator&version=7.0.0
Task("Default").Does(() => {
var file = "./cake-test.csproj";
Information(FileExists(file).ToString());
var props = ParseProject(file, "Release");
});
RunTarget("Default");
Result:
========================================
Default
========================================
True
Task Duration
--------------------------------------------------
Default 00:00:00.0496415
--------------------------------------------------
Total: 00:00:00.0496415
At some point, the work in the Cake.Incubator addin will likely be merged into Cake, and will ship as a new version, however, for now, you will need to bring in the addin directly.

Unable to run/debug robot tests in vscode - robocorp extensions installed

I have installed Robocorp Code as well as Robot Framework Language Server and have configured them. However, I am still having errors when trying to run the tests via the code lens options.
Repo - A webapi repo with a specific folder containing all tests. Lets call it regression.
RF - 4.1.3
Python - 3.8
This is what happens when I click on Run on the code lens for any of the tests -
`PS C:\git\xxxx\regression> C:; cd 'C:\git\xxxx\regression'; &
'C:\Users\xxxx\AppData\Local\Temp\rf-ls-run\run_env_00_smh5defr.bat'
'-u'
'c:\Users\xxxx.vscode\extensions\robocorp.robotframework-lsp-0.47.2\src\robotframework_debug_adapter\run_robot__main__.py'
'--port' '54331' '--no-debug' '--argumentfile'
'C:\git\xxxx\regression\args-local.txt' '--pythonpath'
'c:\git\xxxx\regression\common\lib' '--variable'
'EXECDIR:C:/git/xxxx/regression'
'--prerunmodifier=robotframework_debug_adapter.prerun_modifiers.FilteringTestsSuiteVisitor'
'c:\git\xxxx\regression\api\api_Test.robot'
[ ERROR ] Parsing'--pythonpath' failed: File or directory to execute does not exist.
However, the test starts if I remove the argumentfile parameter but it, of course, fails because its missing arguments from the file.
Do note that the folder specified in pythopath exists and has some python libraries needed for the tests.

C/C++ debugger failing to create and write to raise.c in WSL using VSCode

I am trying to develop in C on WSL(2) (using Ubuntu) for a university course but am having trouble using the built in debugger for C/C++ in VSCode (installed via the C/C++ extension.
For my testings, I am running this code:
#include <assert.h>
int main() {
assert(1==0);
return 0;
}
When running into the assert, the debugger errors and VSC displays the following message on the bottom right corner:
Unable to open 'raise.c': Unable to read file 'vscode-remote://wsl+ubuntu/build/glibc-eX1tMB/glibc-2.31/sysdeps/unix/sysv/linux/raise.c' (Error: Unable to resolve non-existing file 'vscode-remote://wsl+ubuntu/build/glibc-eX1tMB/glibc-2.31/sysdeps/unix/sysv/linux/raise.c').
I have tried every single tutorial, github issue and stackoverflow question's answer but nothing has worked.
I have reason to believe that this has to do with VSC not having some kind of permissions to write/create files because if I press on Create File (which is prompted in the message), It says:
Unable to write file 'vscode-remote://wsl+ubuntu/build/glibc-eX1tMB/glibc-2.31/sysdeps/unix/sysv/linux/raise.c' (NoPermissions (FileSystemError): Error: EACCES: permission denied, mkdir '/build')
but, if I create the folder /build and chmod 777 it, it is able to create the file, but not write anything into it.
Does anyone have a method to solve this?
Also, what is raise.c and why do I need it anyways?
According to the GDB skip function:https://sourceware.org/gdb/onlinedocs/gdb/Skipping-Over-Functions-and-Files.html#Skipping-Over-Functions-and-FilesPuede add it to "SetupCommands" under "configurations" in Launch.json:
{
"description": "Skip glibc files",
"text": "-interpreter-exec console \"skip -gfi build/glibc-YYA7BZ/glibc-2.31//**/*\""
}
But no problem, add WSL + Ubuntu / or VSL + ubuntu, it will ignore the path, it does not solve the problem, which may be valid for other environments, but it is not valid if VSCode uses remote connection. According to article number 811:Disable "Unable to open file" during debugThe developers say that the "Skip" command is also looking online, currently (January 27, 2019) I do not know of any other way. But there are other solutions under this issue, no need to compile Glibc library:
Execute this:
$ sudo apt install glibc-source
$ cd /usr/src/glibc
$ sudo tar xvf glibc-2.31.tar.xz
The "2.31" should be changed to the actual version number Source, and can be seen through the "LS" command. Then add that in "settings" in Launch.json
"sourceFileMap": {
"/build/glibc-YYA7BZ": "/usr/src/glibc"
}
The "YYA7BZ" is changed to the GLIBC suffix appears in the error message. If this method is not valid, you can change the path to: c:/users//AppData/ / / /local packages canonicalGroupLimited.ubuntuonWindows_79RHKP1FNDGSC / /localstate / / rootfs usr/src/glibc, where 79RHKP1FNDGSC should change the folder name on your own system.
Now searching for terminal error information:
Done "/usr/bin/gdb" --interpreter=mi --tty=${DbgTerm} 0<"/tmp/Microsoft-MIEngine-In-p3q623bu.gbr" 1>"/tmp/Microsoft-MIEngine-Out-s4xm3p6g.lqk"
according to the error when executing: ends Call After launching an instance of 'std :: logic_error'This is caused by an empty pointer. One of the possible causes of this problem is that I forgot to add the necessary parameters to add a run program in the "Args" list in "Configurations" in Launch.json.
Source:https://programmerclick.com/article/54012533450/
See this procedure, similar error but in different environment.
https://stackoverflow.com/a/48287761/16842210
In my case, I used try{}catch{} to print the error and saw what was, had nothing to do with raise.c

How can I get Compass to work in Visual Studio via NuGet?

My developer friend who has the luxury of developing in a non-Windows environment has been raving about Compass. I finally decided I wanted to give it a try. I'm tired of trying to keep up with all of the intricacies of cross-browser CSS.
So, I found it on NuGet, and installed it.
I installs to my solutions root directory in the packages directory:
$(SolutionDir)packages\Ruby.Compass.0.12.2.3\
It comes with a Readme that states the following message:
Ruby Compass v. 0.12.2
Compass is installed in its own NuGet package dir, and available by
'compass' command in "packages\Ruby.Compass.0.12.2.3" folder.
To compile Compass files during build, add the next line to the
project pre-build events:
"$(SolutionDir)packages\Ruby.Compass.0.12.2.3\compass" compile
"$(ProjectDir)."
So, I placed the line in my pre-build events, saved, and tried to build my project. However, I get an error as follows:
The command
""$(SolutionDir)packages\Ruby.Compass.0.12.2.3\compass" compile "$(ProjectDir)."" exited with code 1.
Notice: It actually shows the full path to the ProjectDir and SolutionDir as it's supposed too in the error message. I replaced them with the tokens to keep the project name unanimous.
Let me mention that I tried variations of the suggestion pre-build line:
"$(SolutionDir)packages\Ruby.Compass.0.12.2.3\compass" compile "$(ProjectDir)"
"$(SolutionDir)packages\Ruby.Compass.0.12.2.3\compass" compile "$(ProjectDir)css"
"$(SolutionDir)packages\Ruby.Compass.0.12.2.3\compass" compile "$(ProjectDir)css\test.scss"
The first one just removed that trailing .. The second one pointed it to the directory where all my css files are stored. The third one pointed it to the exact file I was trying to compile was located.
I opened up compass.cmd which is the file it is calling, and it looks like the following:
#echo off
"%~dp0ruby\bin\compass" %*
I'm assuming this calls the compass file in the ruby/bin folder, which looks like this:
#!C:/downloads/ruby-2.0.0-p247-x64-mingw32/ruby-2.0.0-p247-x64-mingw32/bin/ruby.exe
#
# This file was generated by RubyGems.
#
# The application 'compass' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'rubygems'
version = ">= 0"
if ARGV.first
str = ARGV.first
str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding
if str =~ /\A_(.*)_\z/
version = $1
ARGV.shift
end
end
gem 'compass', version
load Gem.bin_path('compass', 'compass', version)
From there, I'm not sure what is going on. I'm not a Ruby person.
Is there an issue that I'm overlooking here?
Has anyone else been able to install Ruby.Compass via NuGet?
How can I get this working in Visual Studio without having to fight with Ruby?
From: http://codewith.us/automating-css-generation-in-visual-studio-using-sasscompass/
"Note that, if there are issues with your SCSS files, you will receive some variation of the error below.
Error 36 The command "del "C:Projectspubliccss*.css" /S
compass compile "C:Projectspublic" --force" exited with code 1.
Open your Output window (click View -> Output or press Ctrl+W, O), and select “Build” in the “Show output from:” menu. Scroll up until you find your command in the log and you should get a little more insight into what portion of the command failed."

Why would Eclipse not be able to include a file when running a PHPUnit test?

I have the following class and unit test in a PHP project in Eclipse:
I know my unit test works as I can run it at the command line:
Now I want to run this test from Eclipse. I set up PHP Unit in Eclipse like this:
However, when I run the PHPUnit tests:
It tells me that it can't include the class file:
/usr/bin/php -c /var/folders/UA/UAv38snBHd0QMgEPMCmM9U+++TM/-Tmp-/zend_debug/session4910937990995915704.tmp -d asp_tags=off /Applications/eclipse/plugins/org.phpsrc.eclipse.pti.tools.phpunit_0.5.0.R20101103000000/php/tools/phpunit.php --log-junit /var/folders/UA/UAv38snBHd0QMgEPMCmM9U+++TM/-Tmp-/pti_phpunit/phpunit.xml /Volumes/data/domains/et/extjslayout/phpunittest/tests
PHP Warning: include_once(../Product.php): failed to open stream: No such file or directory in /Volumes/data/domains/et/extjslayout/phpunittest/tests/ProductTest.php on line 3
PHP Warning: include_once(): Failed opening '../Product.php' for inclusion (include_path='/usr/local/PEAR') in /Volumes/data/domains/et/extjslayout/phpunittest/tests/ProductTest.php on line 3
PHP Fatal error: Class 'Product' not found in /Volumes/data/domains/et/extjslayout/phpunittest/tests/ProductTest.php on line 9
Why would PHPUnit be able to find the class when run from the command line but not when run from Eclipse?
When you start something from the command line, the "current directory" has a well-defined meaning: It's the directory where you started the command.
In Eclipse, what is the "current directory"? It's probably the directory from which you started Eclipse or maybe the folder in which Eclipse is installed.
I haven't used PHP in Eclipse before but for other languages, I can set the current directory in the launch config somewhere. If that doesn't work, define a variable which points to your project and then use absolute paths (using that variable as a starting point).
Have same problem. Found only solution by creating tests with internal PHPUnit wizard like at this screenshot:
Source: HowTo create a Test Case Class from a PHP Class
But following investigate show that your test case file should contain reference to tested code for example like this: require_once 'C:\Apache2\htdocs\jobeet\src\Ibw\JobeetBundle\Utils\Jobeet.php';
Other experiments with plugin config not bringing luck. So in my opinion PHPUnit from PHP Tools not well developed plugin. Consider using MakeGood plugin as better alternative.