Problem with running Swift REPL on Windows command prompt - swift

I'm following the swift getting started documentation and I've installed Swift along with its dependencies in Visual studio:
I added Python (v3.9) to the path (although the guide does use 3.7, I'm not sure whether it would make a difference):
path %ProgramFiles(x86)%\Microsoft Visual Studio\Shared\Python39_64;%PATH%
I also entered this line which supposedly adds a few extra parameters which must be passed to the REPL (not entirely sure what exactly it does):
set SWIFTFLAGS=-sdk %SDKROOT% -I %SDKROOT%/usr/lib/swift -L %SDKROOT%/usr/lib/swift/windows
swift repl -target x86_64-unknown-windows-msvc %SWIFTFLAGS%
This starts the REPL and I'm presented with the following:
Welcome to compnerd.org Swift version 5.6.2 (swift-5.6.2-RELEASE).
Type :help for assistance.
1>
I try to enter 1 + 2 as a test to make sure everything is working properly but I am met with an error instead:
Assertion failed: false && "called into swift language runtime stub", file D:\a\1\s\llvm-project\lldb\source\Plugins\LanguageRuntime\Swift\SwiftLanguageRuntime.cpp, line 369
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
#0 0x00007ff739ced645 (C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\lldb.exe+0x1d645)
#1 0x00007ffc6eeb1881 (C:\WINDOWS\System32\ucrtbase.dll+0x71881)
#2 0x00007ffc6eeb2851 (C:\WINDOWS\System32\ucrtbase.dll+0x72851)
#3 0x00007ffc6eeb426e (C:\WINDOWS\System32\ucrtbase.dll+0x7426e)
#4 0x00007ffc6eeb4165 (C:\WINDOWS\System32\ucrtbase.dll+0x74165)
#5 0x00007ffc6eeb44f1 (C:\WINDOWS\System32\ucrtbase.dll+0x744f1)
#6 0x00007ffbf02aa1d5 PyInit__lldb (C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\liblldb.dll+0x83a1d5)
#7 0x00007ffbf525f724 PyInit__lldb (C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\liblldb.dll+0x57ef724)
#8 0x00007ffbf5265031 PyInit__lldb (C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\liblldb.dll+0x57f5031)
#9 0x00007ffbf52628a2 PyInit__lldb (C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\liblldb.dll+0x57f28a2)
#10 0x00007ffbf525cbcb PyInit__lldb (C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\liblldb.dll+0x57ecbcb)
#11 0x00007ffbeffd7d2b PyInit__lldb (C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\liblldb.dll+0x567d2b)
#12 0x00007ffbeffe6c52 PyInit__lldb (C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\liblldb.dll+0x576c52)
#13 0x00007ffbeffb4806 PyInit__lldb (C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\liblldb.dll+0x544806)
#14 0x00007ffbeff6265a PyInit__lldb (C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\liblldb.dll+0x4f265a)
#15 0x00007ffbeff6106e PyInit__lldb (C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\liblldb.dll+0x4f106e)
#16 0x00007ffc6ee61bb2 (C:\WINDOWS\System32\ucrtbase.dll+0x21bb2)
#17 0x00007ffc70947034 (C:\WINDOWS\System32\KERNEL32.DLL+0x17034)
#18 0x00007ffc713a2651 (C:\WINDOWS\SYSTEM32\ntdll.dll+0x52651)
I've tried uninstalling and reinstalling components and playing with the parameters, but to no avail.
Any help would be greatly appreciated.

This is not a true solution, but a workaround that is working on my Windows PC. Assuming Swift is installed on its default location, you need to
set SDKROOT environment variable to C:\Library\Developer\Platforms\Windows.platform\Developer\SDKs\Windows.sdk
(just once in your Windows system environment variables)
instead of running swift repl, you run
lldb "--repl=-sdk %SDKROOT% -target x86_64-unknown-windows-msvc"
(you can make this as a swiftrepl.cmd file and put it into a folder on your path)
as first command you enter
:expr (void*)LoadLibraryA("C:/Program Files/swift/runtime-development/usr/bin/swiftCore.dll")
I know it is ugly, but it works.
lldb "--repl=-sdk %SDKROOT% -target x86_64-unknown-windows-msvc"
Welcome to compnerd.org Swift version 5.7 (swift-5.7-RELEASE).
Type :help for assistance.
1> :expr (void*)LoadLibraryA("C:/Program Files/swift/runtime-development/usr/bin/swiftCore.dll")
(void *) $0 = 0x00007ffa2a090000
1> 1+2
$R0: Int = 3
2> let str="test"
str: String = "test"

Related

Mac Flutter Install: can't access the lockfile

I've been able to use flutter to create apps on my mac using my "work user account".
I now want to be able to login as myself and create apps so I've created a new user. I've made the workaccount path to flutter rw for "staff" and using my personalaccount I can access all the files. ls -l confirms I have rw access to the lockfile. I tried deleting the lockfile but that didn't help.
I've updated $PATH and my workaccount flutter is there when I echo.
I've tried killall -9 dart on my workaccount .
When I run flutter doctor -v I still get this:
Flutter failed to open a file at "/Users/workaccount/Development/flutter/bin/cache/lockfile". > The flutter tool cannot access the file or directory.
Please ensure that the SDK and/or project is installed in a location that has read/write permissions for the current user.
#0 throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
#1 _throwFileSystemException (package:flutter_tools/src/base/error_handling_io.dart:778:3)
#2 _handlePosixException (package:flutter_tools/src/base/error_handling_io.dart:726:3)
#3 _runSync (package:flutter_tools/src/base/error_handling_io.dart:583:7)
#4 ErrorHandlingFile.openSync (package:flutter_tools/src/base/error_handling_io.dart:291:12)
#5 Cache.lock (package:flutter_tools/src/cache.dart:304:24)
#6 FlutterCommandRunner.runCommand. (package:flutter_tools/src/runner/flutter_command_runner.dart:240:31)
#7 FlutterCommandRunner.runCommand. (package:flutter_tools/src/runner/flutter_command_runner.dart:236:13)
#8 AppContext.run. (package:flutter_tools/src/base/context.dart:150:29)
#9 AppContext.run. (package:flutter_tools/src/base/context.dart:150:7)
#10 _rootRun (dart:async/zone.dart:1354:13)
#11 _CustomZone.run (dart:async/zone.dart:1258:19)
#12 _runZoned (dart:async/zone.dart:1789:10)
#13 runZoned (dart:async/zone.dart:1711:10)
#14 AppContext.run (package:flutter_tools/src/base/context.dart:149:12)
#15 FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:232:19)
#16 run.. (package:flutter_tools/runner.dart:62:9)
#17 AppContext.run. (package:flutter_tools/src/base/context.dart:150:19)
#18 main (package:flutter_tools/executable.dart:91:3)
My mac skills aren't great, can anyone suggest something that might work?
you may run this command :
$ sudo chown -R <username> /Users/workaccount/Development/flutter/bin/cache/lockfile
more info :
Check permission for the mentioned directory via:
ls -l /home/raphael/flutter/
the flutter subfolder in there should have the same user id (or the group) as your current user, with whom you are trying to create the project.
If not, while being in the folder mentioned above, try to change permission on the folder via:
chown -R YOUR_USERNAME flutter
Run the first command again to verify that the apropriate user is now shown on the folder. Then try to create the project again.
Update
If you want to have permission on each account you can do it:
sudo chmod 777 /Users/workaccount/Development/flutter/bin/cache/lockfile
you go to documents and command+up+. and you can see .bashrc, you must add your path (export PATH="$PATH:/Users/ecemE/flutter/bin"
my path) after terminal off and open again, write flutter doctor and fix this problem :D

Flutter Installation: OS Error: Access is denied, errno=5

I tried installing flutter by following the steps at https://flutter.dev/docs/get-started/install , but kept running into the following error when inputting flutter in to Command Prompt:
Unhandled exception: FileSystemException: Cannot open file, path =
'C:\Users\matt\AppData\Roaming.flutter_tool_state' (OS Error: Access
is denied. , errno = 5) #0 _File.throwIfError
(dart:io/file_impl.dart:645:7) #1 _File.openSync
(dart:io/file_impl.dart:489:5) #2 _File.writeAsBytesSync
(dart:io/file_impl.dart:614:31) #3 _File.writeAsStringSync
(dart:io/file_impl.dart:638:5) #4 ForwardingFile.writeAsStringSync
(package:file/src/forwarding/forwarding_file.dart:154:16) #5
ErrorHandlingFile.writeAsStringSync.
(package:flutter_tools/src/base/error_handling_file_system.dart:137:22)
#6 ErrorHandlingFile._runSync (package:flutter_tools/src/base/error_handling_file_system.dart:163:16)
#7 ErrorHandlingFile.writeAsStringSync (package:flutter_tools/src/base/error_handling_file_system.dart:136:5)
#8 Config._flushValues (package:flutter_tools/src/base/config.dart:86:11) #9 Config.setValue
(package:flutter_tools/src/base/config.dart:75:5) #10
_DefaultPersistentToolState.isRunningOnBot= (package:flutter_tools/src/persistent_tool_state.dart:120:45) #11
BotDetector.isRunningOnBot
(package:flutter_tools/src/base/bot_detector.dart:46:33) #12 isRunningOnBot
(package:flutter_tools/src/globals.dart:98:48) #13
runInContext.runnerWrapper
(package:flutter_tools/src/context_runner.dart:63:34) #14
AppContext.run.
(package:flutter_tools/src/base/context.dart:150:29) #15 _rootRun
(dart:async/zone.dart:1184:13) #16 _CustomZone.run
(dart:async/zone.dart:1077:19) #17 _runZoned
(dart:async/zone.dart:1619:10) #18 runZoned
(dart:async/zone.dart:1539:10) #19 AppContext.run
(package:flutter_tools/src/base/context.dart:149:18) #20 runInContext
(package:flutter_tools/src/context_runner.dart:67:24) #21 run
(package:flutter_tools/runner.dart:48:10) #22 main
(package:flutter_tools/executable.dart:69:9) #23 main
(file:///C:/b/s/w/ir/k/archive/flutter/packages/flutter_tools/bin/flutter_tools.dart:8:3)
#24 _startIsolate. (dart:isolate-patch/isolate_patch.dart:299:32) #25
_RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)
Any help would be appreciated!
(OS Error: Access is denied. , errno = 5)
Error 5: Access denied is a known issue on Windows 10. This error prevents you from installing software on your computer and accessing or modifying certain files.
The reason for this issue is the non-availability of the permissions. Windows 10 will prevent you from installing if you don’t have the Administrator privileges or if your account is not the administrator account.
How to Fix Error 5 Access Denied?
It worked for me disabling the "Controlled folder access" option in Windows Defender

Troubleshooting Math::PARI crash inside mod_perl

I build (brewed) my own perl, then the mod_perl module, and then installed all required perl libraries.
The mod_perl environment works fine. One-liners with Math::PARI also work, for example:
perl -MMath::Pari -e "use Math::Pari ':float', 'type_name'; warn type_name 22222222222222222222222;"
t_INT at -e line 1.
However, when I start apache2/mod_perl and try to load Math::PARI I get the following crash:
root#paris:/usr/apps/test/config# gdb -q /usr/sbin/apache2
Reading symbols from /usr/sbin/apache2...(no debugging symbols found)...done.
(gdb) set args -f /usr/apps/test/config/httpd.conf -k start
(gdb) run
Starting program: /usr/sbin/apache2 -f /usr/apps/test/config/httpd.conf -k start
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff367bea7 in moveoffstack_newer_than () from /opt/perl5/perlbrew/perls/perl-5.14.2/lib/site_perl/5.14.2/x86_64-linux-thread-multi/auto/Math/Pari/Pari.so
(gdb) bt
#0 0x00007ffff367bea7 in moveoffstack_newer_than () from /opt/perl5/perlbrew/perls/perl-5.14.2/lib/site_perl/5.14.2/x86_64-linux-thread-multi/auto/Math/Pari/Pari.so
#1 0x00007ffff367c008 in XS_Math__Pari_DESTROY () from /opt/perl5/perlbrew/perls/perl-5.14.2/lib/site_perl/5.14.2/x86_64-linux-thread-multi/auto/Math/Pari/Pari.so
#2 0x00007ffff5bca17c in Perl_pp_entersub () from /opt/perl5/perlbrew/perls/perl-5.14.2/lib/5.14.2/x86_64-linux-thread-multi/CORE/libperl.so
#3 0x00007ffff5b5c771 in Perl_call_sv () from /opt/perl5/perlbrew/perls/perl-5.14.2/lib/5.14.2/x86_64-linux-thread-multi/CORE/libperl.so
#4 0x00007ffff5bd0629 in Perl_sv_clear () from /opt/perl5/perlbrew/perls/perl-5.14.2/lib/5.14.2/x86_64-linux-thread-multi/CORE/libperl.so
#5 0x00007ffff5bd0ce2 in Perl_sv_free2 () from /opt/perl5/perlbrew/perls/perl-5.14.2/lib/5.14.2/x86_64-linux-thread-multi/CORE/libperl.so
#6 0x00007ffff5bcb647 in S_visit () from /opt/perl5/perlbrew/perls/perl-5.14.2/lib/5.14.2/x86_64-linux-thread-multi/CORE/libperl.so
#7 0x00007ffff5bd1456 in Perl_sv_clean_objs () from /opt/perl5/perlbrew/perls/perl-5.14.2/lib/5.14.2/x86_64-linux-thread-multi/CORE/libperl.so
#8 0x00007ffff5b5e4a7 in perl_destruct () from /opt/perl5/perlbrew/perls/perl-5.14.2/lib/5.14.2/x86_64-linux-thread-multi/CORE/libperl.so
#9 0x00007ffff7f8d477 in modperl_perl_destruct () from /opt/perl5/perlbrew/perls/perl-5.14.2/usr/lib/apache2/modules/mod_perl.so
#10 0x00007ffff7f7d81e in modperl_interp_destroy () from /opt/perl5/perlbrew/perls/perl-5.14.2/usr/lib/apache2/modules/mod_perl.so
#11 0x00007ffff7f7e3c5 in modperl_tipool_destroy () from /opt/perl5/perlbrew/perls/perl-5.14.2/usr/lib/apache2/modules/mod_perl.so
#12 0x00007ffff7f7d882 in modperl_interp_pool_destroy () from /opt/perl5/perlbrew/perls/perl-5.14.2/usr/lib/apache2/modules/mod_perl.so
#13 0x00007ffff776499e in apr_pool_destroy () from /usr/lib/libapr-1.so.0
#14 0x00007ffff7764b95 in apr_pool_clear () from /usr/lib/libapr-1.so.0
#15 0x0000555555585e67 in main ()
More info about the environment:
Debian 7.11
perl-5.14.2 (same as system perl but built with perlbrew)
mod_perl2 (built manually)
How can I get to the root cause of this?
Math::Pari is not thread safe, so probably you are running under threaded MPM, try installing prefork model for Apache2. If you're on Debian/Ubuntu try this:
sudo apt-get install apache2-mpm-prefork

trace down sigusr1, debug mex with gdb

Is there a way to trace down who sends the sigusr1?
It is for mex file created for Ubuntu, which hangs for certain condition. So I did:
1, mex -g *.c (create .mex file)
2 matlab -Dgdb
3 handle SIGUSR1 stop print
4 run -nojvm (run matlab without gui)
5 dbmex on
6 run my executable
then it prints out:
MEX FILE: /home/X/Desktop/Test/test.mexa 64 entry point located at address 0xd11ea144
Add breakpoints at the debugger prompt and issue a "continue" to resume execution of MATLAB
If I do "continue", my executable runs, then it hangs there again(I think the same as before).
I tried "bt" and "where", but still no clue where I get the SIGUSR1 and why it hangs.
For "where", I get:
#0 0x00007ffff5962ca4 in pthread_cond_wait##GLIBC_2.3.2 () from /lib/x86_64-linux-gnu/libpthread.so.0
#1 0x00007ffff69d7015 in mcr_run_main(boost::function0<int> const&, bool, bool)() from /usr/local/MATLAB/R2013b/bin/glnxa64/libmwmcr.so
#2 0x0000000000405291 in ?? ()
#3 0x00007ffff55b0ea5 in __libc_start_main () from /lib/x86_64-linux-gnu/libc.so.6
#4 0x0000000000405489 in ?? ()
#5 0x00007fffffffded8 in ?? ()
#6 0x000000000000001c in ?? ()
#7 0x0000000000000002 in ?? ()
#8 0x00007fffffffe208 in ?? ()
#9 0x00007fffffffe234 in ?? ()
#10 0x000000000000000 in ?? ()
Can anyone help here point out the correct way to trace down the signal SIGUSR1 (which I think cause my exe to hang)? Thanks a lot!!
Updates:
set break points as suggested in the source files before and around suspicious code. then continue to track down bugs.
LJ
When stopped at a signal, you can print $_siginfo, and then examine the fields of this object to find the PID of the process that sent the signal.

magento pdo_mysql extension is not installed in magento

I'm getting this error after moving the application to another host. It's working locally, without any problems, but the issue started after moving to the webhost. Please tell me what I'm doing wrong.
pdo_mysql extension is not installed
Trace:
#0 D:\Hosting\11486590\html\shopping\magento\lib\Zend\Db\Adapter\Abstract.php(459): Varien_Db_Adapter_Pdo_Mysql->_connect()
#1 D:\Hosting\11486590\html\shopping\magento\lib\Zend\Db\Adapter\Pdo\Abstract.php(238): Zend_Db_Adapter_Abstract->query('SET NAMES utf8', Array)
#2 D:\Hosting\11486590\html\shopping\magento\lib\Varien\Db\Adapter\Pdo\Mysql.php(419): Zend_Db_Adapter_Pdo_Abstract->query('SET NAMES utf8', Array)
#3 D:\Hosting\11486590\html\shopping\magento\app\code\core\Mage\Core\Model\Resource.php(169): Varien_Db_Adapter_Pdo_Mysql->query('SET NAMES utf8')
#4 D:\Hosting\11486590\html\shopping\magento\app\code\core\Mage\Core\Model\Resource.php(110): Mage_Core_Model_Resource->_newConnection('pdo_mysql', Object(Mage_Core_Model_Config_Element))
#5 D:\Hosting\11486590\html\shopping\magento\app\code\core\Mage\Core\Model\Resource\Db\Abstract.php(320): Mage_Core_Model_Resource->getConnection('core_write')
#6 D:\Hosting\11486590\html\shopping\magento\app\code\core\Mage\Core\Model\Resource\Db\Abstract.php(350): Mage_Core_Model_Resource_Db_Abstract->_getConnection('write')
#7 D:\Hosting\11486590\html\shopping\magento\app\code\core\Mage\Core\Model\Resource\Db\Abstract.php(335): Mage_Core_Model_Resource_Db_Abstract->_getWriteAdapter()
#8 D:\Hosting\11486590\html\shopping\magento\app\code\core\Mage\Core\Model\Resource\Cache.php(53): Mage_Core_Model_Resource_Db_Abstract->_getReadAdapter()
#9 D:\Hosting\11486590\html\shopping\magento\app\code\core\Mage\Core\Model\Cache.php(455): Mage_Core_Model_Resource_Cache->getAllOptions()
#10 D:\Hosting\11486590\html\shopping\magento\app\code\core\Mage\Core\Model\Cache.php(497): Mage_Core_Model_Cache->_initOptions()
#11 D:\Hosting\11486590\html\shopping\magento\app\code\core\Mage\Core\Model\App.php(1183): Mage_Core_Model_Cache->canUse('config')
#12 D:\Hosting\11486590\html\shopping\magento\app\code\core\Mage\Core\Model\Config.php(414): Mage_Core_Model_App->useCache('config')
#13 D:\Hosting\11486590\html\shopping\magento\app\code\core\Mage\Core\Model\Config.php(294): Mage_Core_Model_Config->_canUseCacheForInit()
#14 D:\Hosting\11486590\html\shopping\magento\app\code\core\Mage\Core\Model\App.php(413): Mage_Core_Model_Config->loadModulesCache()
#15 D:\Hosting\11486590\html\shopping\magento\app\code\core\Mage\Core\Model\App.php(343): Mage_Core_Model_App->_initModules()
#16 D:\Hosting\11486590\html\shopping\magento\app\Mage.php(683): Mage_Core_Model_App->run(Array)
#17 D:\Hosting\11486590\html\shopping\magento\index.php(87): Mage::run('', 'store')
#18 {main}
Check of your server has the pdo_mysql extension installed.
Create a file info.php and in it write <?php phpinfo() ?>
access the file with your browser and search for "pdo"
if not found install it or ask your server administrator to install it for you