I use CRA + Electron. And I build my project by target electron-renderer.
It works well while loading files in build folder, but it throws error when I develop and load url localhost:3000.
I guess the reason is that I use node api and electron api in react components. Anybody has the solution ? Thanks.
TypeError: fs.existsSync is not a function
5 | var pathFile = path.join(__dirname, 'path.txt');
6 |
7 | function getElectronPath() {
> 8 | if (fs.existsSync(pathFile)) {
9 | var executablePath = fs.readFileSync(pathFile, 'utf-8');
10 |
11 | if (process.env.ELECTRON_OVERRIDE_DIST_PATH) {
Related
I'm trying to configure Guile to use readline.
Here's my ~/.guile:
(use-modules (ice-9 readline))
(there was more, this one line is sufficient to have this failure)
Here's a log of my interaction:
agam#ssdnodes-61de65ea00d0b:~$ guile
guile: warning: failed to install locale
Backtrace:
In ice-9/boot-9.scm:
1752:10 12 (with-exception-handler _ _ #:unwind? _ # _)
In unknown file:
11 (apply-smob/0 #<thunk 7fb7984660c0>)
In ice-9/boot-9.scm:
724:2 10 (call-with-prompt ("prompt") #<procedure 7fb796fc2e80 ?> ?)
In ice-9/eval.scm:
619:8 9 (_ #(#(#<directory (guile-user) 7fb79846cc80>)))
In unknown file:
8 (primitive-load "/home/agam/.guile")
In ice-9/eval.scm:
721:20 7 (primitive-eval (use-modules (ice-9 readline)))
In ice-9/psyntax.scm:
1230:36 6 (expand-top-sequence ((use-modules (ice-9 readline))) _ ?)
1222:19 5 (parse _ (("placeholder" placeholder)) ((top) #(# # ?)) ?)
259:10 4 (parse _ (("placeholder" placeholder)) (()) _ c&e (eval) ?)
In ice-9/boot-9.scm:
3927:20 3 (process-use-modules _)
222:17 2 (map1 (((ice-9 readline))))
3928:31 1 (_ ((ice-9 readline)))
3329:6 0 (resolve-interface (ice-9 readline) #:select _ #:hide _ ?)
ice-9/boot-9.scm:3329:6: In procedure resolve-interface:
no code for module (ice-9 readline)
If it helps, I'm doing this within Guile installed via guix install guile. I have installed glibc-locales, and GUIX_LOCPATH is set to "$HOME/.guix-profile/lib/locale"
Turns out the locale ... warning was a red herring, I was missing the readline package.
I needed to
guix install guile-readline, followed by
. "$GUIX_PROFILE/etc/profile"
After that, guile starts up fine.
I have a F# fake script which works with Nuge.Core to extract package files. If I try to do this with c# console app everything works properly. However if I execute exactly the same script in a f# fake script it is not working. There are so many dependencies here and I have no idea where to look for a help: docker.dotnet, fake, f#, nuget.core
To reproduce this you need to download Docker.DotNet.2.124.3.nupkg
For the c# sample you need console application and to install nuget.core nuget package. This is working!
class Program
{
static void Main()
{
var zip = new NuGet.ZipPackage(#"Docker.DotNet.2.124.3.nupkg");
foreach (var file in zip.GetFiles())
{
System.Console.WriteLine(file.Path);
}
}
}
For the f# sample you need these two files side by side:
https://gist.github.com/mynkow/e6f0e550fcacc268dd1e9b743e17d344
ERROR:
==============================================================================
FsiEvaluationException:
Error: System.InvalidOperationException: 'NETStandard.Library' already has a dependency defined for 'Microsoft.NETCore.Platforms'.
at NuGet.Manifest.ValidateDependencySets(IPackageMetadata metadata)
at NuGet.Manifest.Validate(Manifest manifest)
at NuGet.Manifest.ReadFrom(Stream stream, IPropertyProvider propertyProvider, Boolean validateSchema)
at NuGet.LocalPackage.ReadManifest(Stream manifestStream)
at NuGet.ZipPackage.EnsureManifest(Func`1 manifestStreamFactory)
at NuGet.ZipPackage..ctor(String filePath, Boolean enableCaching)
at <StartupCode$FSI_0005>.$FSI_0005_Test$fsx.main#() in C:\Users\mynkow\Desktop\Reproduce\test.fsx:line 12
Stopped due to error
Output: [Loading C:\Users\mynkow\Desktop\Reproduce\test.fsx]
==============================================================================
Input: C:\Users\mynkow\Desktop\Reproduce\test.fsx
\Arguments:
C:\fsi.exe
Exception: Yaaf.FSharp.Scripting.FsiEvaluationException: Error while compiling or executing fsharp snippet. ---> System.Exception: Operation failed. The error text has been print the error stream. To return the corresponding FSharpErrorInfo use the EvalInteractionNonThrowing, EvalScriptNonThrowing or EvalExpressionNonThrowing
at Microsoft.FSharp.Compiler.Interactive.Shell.FsiEvaluationSession.commitResult[a,b](FSharpChoice`2 res)
at Microsoft.FSharp.Compiler.Interactive.Shell.FsiEvaluationSession.EvalScript(String filePath)
at Yaaf.FSharp.Scripting.Helper.evalScript#1303.Invoke(String arg00) in C:\code\FAKE\paket-files\matthid\Yaaf.FSharp.Scripting\src\source\Yaaf.FSharp.Scripting\YaafFSharpScripting.fs:line 1303
at Yaaf.FSharp.Scripting.Helper.save_#1276-2.Invoke(Unit unitVar0) in C:\code\FAKE\paket-files\matthid\Yaaf.FSharp.Scripting\src\source\Yaaf.FSharp.Scripting\YaafFSharpScripting.fs:line 1277
at Yaaf.FSharp.Scripting.Helper.consoleCapture[a](TextWriter out, TextWriter err, FSharpFunc`2 f) in C:\code\FAKE\paket-files\matthid\Yaaf.FSharp.Scripting\src\source\Yaaf.FSharp.Scripting\YaafFSharpScripting.fs:line 1221
at Yaaf.FSharp.Scripting.Helper.redirectOut#1247[a](Boolean preventStdOut, OutStreamHelper out, OutStreamHelper err, FSharpFunc`2 f) in C:\code\FAKE\paket-files\matthid\Yaaf.FSharp.Scripting\src\source\Yaaf.FSharp.Scripting\YaafFSharpScripting.fs:line 1254
at Yaaf.FSharp.Scripting.Helper.save_#1275-1.Invoke(String text) in C:\code\FAKE\paket-files\matthid\Yaaf.FSharp.Scripting\src\source\Yaaf.FSharp.Scripting\YaafFSharpScripting.fs:line 1276
--- End of inner exception stack trace ---
at Yaaf.FSharp.Scripting.Helper.save_#1275-1.Invoke(String text) in C:\code\FAKE\paket-files\matthid\Yaaf.FSharp.Scripting\src\source\Yaaf.FSharp.Scripting\YaafFSharpScripting.fs:line 1284
at Yaaf.FSharp.Scripting.Helper.session#1306.Yaaf-FSharp-Scripting-IFsiSession-EvalScriptWithOutput(String ) in C:\code\FAKE\paket-files\matthid\Yaaf.FSharp.Scripting\src\source\Yaaf.FSharp.Scripting\YaafFSharpScripting.fs:line 1308
at Fake.FSIHelper.runScriptUncached(Boolean useCache, String scriptPath, IEnumerable`1 fsiOptions, Boolean printDetails, CacheInfo cacheInfo, TextWriter out, TextWriter err) in C:\code\FAKE\src\app\FakeLib\FSIHelper.fs:line 471
System.InvalidOperationException: 'NETStandard.Library' already has a dependency defined for 'Microsoft.NETCore.Platforms'.
at NuGet.Manifest.ValidateDependencySets(IPackageMetadata metadata)
at NuGet.Manifest.Validate(Manifest manifest)
at NuGet.Manifest.ReadFrom(Stream stream, IPropertyProvider propertyProvider, Boolean validateSchema)
at NuGet.LocalPackage.ReadManifest(Stream manifestStream)
at NuGet.ZipPackage.EnsureManifest(Func`1 manifestStreamFactory)
at NuGet.ZipPackage..ctor(String filePath, Boolean enableCaching)
at <StartupCode$FSI_0005>.$FSI_0005_Test$fsx.main#() in C:\Users\mynkow\Desktop\Reproduce\test.fsx:line 12
Stopped due to error
I have tried with the 5 latest versions of all possible dependencies and the results are exactly the same => c# is working, f# is not. Do you have any clue or just anything which you can advise me to try to fix this?
DIRTY SOLUTION:
This is how the Docker.DotNet.2.124.3.nupkg looks like inside
If I remove for example the netstandard1.6 everything works. This means that the problem is in nuget.core, right? But why it is working in c# console app? No idea!
UPDATE: I am able to execute properly the code from F# console application
I've downloaded the packages with paket, and changed the script this way:
#r #"./packages/FAKE/tools/FakeLib.dll"
#r #"./packages/NuGet.Core/lib/net40-Client/NuGet.Core.dll"
open System
open System.Collections.Generic
open System.IO
open Fake
Target "Test" (fun _ ->
printfn "=============================================================================="
global.NuGet.ZipPackage(#"Docker.DotNet.2.124.3.nupkg").GetFiles() |> Seq.iter(fun x -> printfn "%s" x.Path )
)
RunParameterTargetOrDefault "target" "test"
It gives this
Microsoft (R) F# Interactive version 14.0.23413.0
Copyright (c) Microsoft Corporation. All Rights Reserved.
For help type #help;;
>
--> Referenced 'C:\tmp\visualfsharp.issue.nuget\./packages/FAKE/tools/FakeLib.dll'
--> Referenced 'C:\tmp\visualfsharp.issue.nuget\./packages/NuGet.Core/lib/net40-Client/NuGet.Core.dll'
Building project with version: LocalBuild
Shortened DependencyGraph for Target Test:
<== Test
The resulting target order is:
- Test
Starting Target: Test
==============================================================================
Running build failed.
Error:
System.InvalidOperationException: The schema version of 'Docker.DotNet' is incompatible with version 1.6.30117.9648 of NuGet. Please upgrade NuGet to the latest version from http://go.microsoft.com/fwlink/?LinkId=213942.
at NuGet.Manifest.CheckSchemaVersion(XDocument document)
at NuGet.Manifest.ValidateManifestSchema(XDocument document, String schemaNamespace)
at NuGet.Manifest.ReadFrom(Stream stream, IPropertyProvider propertyProvider)
at NuGet.ZipPackage.EnsureManifest()
at FSI_0002.clo#9.Invoke(Unit _arg1) in C:\tmp\visualfsharp.issue.nuget\test.fsx:line 11
at Fake.TargetHelper.runSingleTarget(TargetTemplate`1 target) in C:\code\FAKE\src\app\FakeLib\TargetHelper.fs:line 493
---------------------------------------------------------------------
Build Time Report
No target was successfully completed
---------------------------------------------------------------------
---------------------------------------------------------------------
val it : unit = ()
>
The version of NuGet.Core is 2.12, and I'm seeing it is referencing Microsoft.Web.Xdt which is not loaded.
Maybe you can achieve what you want by simply using paket and adding Docker.DotNet as a dependency, it will extract it for you.
If you have reproducible error that you described, please make a zip and post an issue to visualfsharp repository.
I've been using the Guinness test framework for some functional testing in my Dart library.
I think one of the new updates to either WebStorm or Dart SDK broke.
I have the following:
import 'package:guinness/guinness.dart';
import 'package:tickets/shared/schemas.dart';
import 'package:tickets/db/seeder.dart';
import 'package:tickets/db/db_config.dart';
import '../bin/mongo_model.dart';
main() {
DbConfigValues config = new DbConfigValues();
MongoModel model = new MongoModel(config.testDbName, config.testDbURI, config.testDbSize);
//A Test DTO
RouteDTO routeDTO = new RouteDTO()..duration=120..price1=90.00..price2=91.00..price3=95.00..seats=7;
describe("The Ticket MongoModel", () {
it("should create a record DTO and write to the db", () {
var originalID = routeDTO.id;
return model.createByItem(routeDTO).then(( var dto ) {
expect(originalID).toBeNull();
expect(routeDTO.id).toBeNotNull();
expect(dto.id).toEqual(routeDTO.id);
});
});
});
}
Which results in:
/usr/local/opt/dart/libexec/bin/dart --ignore-unrecognized-flags --checked --enable-vm-service:52158 --trace_service_pause_events /private/var/folders/br/4n3vt5lj0qq11xk0fdmjk9y80000gn/T/jetbrains_unit_config.dart
Testing started at 3:31 PM ...
Unhandled exception:
Could not resolve a package location for base at file:///private/var/folders/br/4n3vt5lj0qq11xk0fdmjk9y80000gn/T/jetbrains_unit_config.dart
#0 _handlePackagesReply (dart:_builtin:416)
#1 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:148)
Observatory listening on http://127.0.0.1:52158
Process finished with exit code 255
Question: How do i get guiness working with WebStorm in 11EAP.
I suggest to run the test as a standard command line Dart application. You can create corresponding run configuration manually (Run | Edit Configurations | [+] | Dart Command Line App), or remove current DartUnit run configuraton (Run | Edit Configurations) and then right click the main file. You won't get test result tree this way, but you'll see test results in the IDE console.
According to Alexanders answer I found a solution for me - I'm using the bash plugin for this...
I'm using CircleCI to check for security issues and this is cropping up as an error, though I'm not sure that it is.
This is the line of code that is causing one of the scripting errors:
= link_to t(:delete), main_app.board_comment_path(#board, comment), method: :delete
Is this a valid security issue? Is there any way for me to make Brakeman accept these parameters as safe? I read up on --url-safe-methods but I couldn't figure out a way to make it work.
Used this link as a guide https://github.com/presidentbeef/brakeman/pull/45
Running bundle exec brakeman -A -q --exit-on-warn, this is the error report:
+BRAKEMAN REPORT+
Application path: ****
Rails version: 4.2.2
Brakeman version: 3.0.4
Started at 2015-06-26 14:10:14 -0700
Duration: 1.8311 seconds
Checks run: BasicAuth, ContentTag, CreateWith, CrossSiteScripting, DefaultRoutes, Deserialize, DetailedExceptions, DigestDoS, EscapeFunction, Evaluation, Execute, FileAccess, FileDisclosure, FilterSkipping, ForgerySetting, HeaderDoS, I18nXSS, JRubyXML, JSONEncoding, JSONParsing, LinkTo, LinkToHref, MailTo, MassAssignment, ModelAttrAccessible, ModelAttributes, ModelSerialize, NestedAttributes, NumberToCurrency, QuoteTableName, Redirect, RegexDoS, Render, RenderDoS, RenderInline, ResponseSplitting, SQL, SQLCVEs, SSLVerify, SafeBufferManipulation, SanitizeMethods, SelectTag, SelectVulnerability, Send, SendFile, SessionSettings, SimpleFormat, SingleQuotes, SkipBeforeFilter, StripTags, SymbolDoS, SymbolDoSCVE, TranslateBug, UnsafeReflection, UnscopedFind, ValidationRegex, WithoutProtection, XMLDoS, YAMLParsing
+SUMMARY+
+-------------------+-------+
| Scanned/Reported | Total |
+-------------------+-------+
| Controllers | 23 |
| Models | 9 |
| Templates | 53 |
| Errors | 0 |
| Security Warnings | 2 (0) |
+-------------------+-------+
+----------------------+-------+
| Warning Type | Total |
+----------------------+-------+
| Cross Site Scripting | 2 |
+----------------------+-------+
View Warnings:
+------------+------------------------------------------------------------------+----------------------+-------------------->>
| Confidence | Template | Warning Type | Message >>
+------------+------------------------------------------------------------------+----------------------+-------------------->>
| Medium | boards/show (BoardsController#show) | Cross Site Scripting | Unsafe parameter va>>
| Medium | boards/show (BoardsController#show) | Cross Site Scripting | Unsafe parameter va>>
+------------+------------------------------------------------------------------+----------------------+-------------------->>
This is (almost certainly) a false positive, assuming board_comment_path returns a path.
The reason Brakeman warns about URLs in link_to is because it is possible to set URLs like javascript:dangerous_stuff_here(). A common example would be user profiles linking to a user's website.
--url-safe-methods only applies to methods wrapping input to link_to. For example, link_to 'stuff', safe_url(some_input).
However, after https://github.com/presidentbeef/brakeman/pull/674 Brakeman will stop warning about path helpers in URLs and also expand --safe-methods/--url-safe-methods to match all types of methods.
I have a grails application which is failing at runtime in a cryptic way
(cyptic to me anyway)
with a ArrayIndexOutOfBoundsException when I visit the scaffolded /imca2/imcaReferral/index.
* now edited to put solution at end *
There are about a dozen domain classes.
I haven't got round to worrying about the UI yet so the controllers are all dynamically scaffolded.
All the other controllers work OK.
This Controller:
package com.ubergen
class ImcaReferralController {
def scaffold = ImcaReferral
}
For this Domain:
package com.ubergen
class ImcaReferral {
private def todayDate = new Date()
String advocacyReferenceNum = ""
[snip a lot of code]
String toString() {
"${this.advocacyReferenceNum}: ${this.client?this.client:'-'}${this.referralIssue?', '+this.referralIssue:''}"
}
}
(I don't want to post the domain class here as its huge).
Produces this stacktrace:
|Server running. Browse to http://localhost:8080/imca2
| Error 2014-03-12 18:48:24,935 [http-bio-8080-exec-3] ERROR errors.GrailsExceptionResolver - ArrayIndexOutOfBoundsException occurred when processing request: [GET] /imca2/imcaReferral/index
0. Stacktrace follows:
Message: 0
Line | Method
->> 55 | <init> in grails.orm.PagedResultList
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 15 | $tt__index in com.ubergen.ImcaReferralController
| 191 | doFilter . in grails.plugin.cache.web.filter.PageFragmentCachingFilter
| 63 | doFilter in grails.plugin.cache.web.filter.AbstractFilter
| 1146 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 701 | run . . . in java.lang.Thread
Cleaning and (re)compiling make no difference.
The domain class is being used during bootstrapping to push data successfully into the database, so it works to that extent.
I can run the application from the command line instead of from inside eclipse/STS. The same error is thrown.
run-app --noreloading makes no difference either (clutching at straws now). And run-war also produces the same error.
run-app --verbose shows:
| Error 2014-03-12 19:58:37,745 [http-bio-8080-exec-1] ERROR errors.GrailsExceptionResolver - ArrayIndexOutOfBoundsException occurred when processing request: [GET] /imca2/imcaReferral/index
0. Stacktrace follows:
java.lang.ArrayIndexOutOfBoundsException: 0
at org.hibernate.criterion.Order.toSqlString(Order.java:73)
at org.hibernate.loader.criteria.CriteriaQueryTranslator.getOrderBy(CriteriaQueryTranslator.java:394)
[snip]
at grails.orm.PagedResultList.<init>(PagedResultList.java:55)
[snip]
at com.ubergen.ImcaReferral.list(ImcaReferral.groovy)
[snip]
at com.ubergen.ImcaReferralController.$tt__index(script1394654146228610896735.groovy:15)
[snip]
So the index page calls the domain's list() and this is a problem in some way but not enough of a way that its getting mentioned in the stacktrace.
Where should I look first for the problem?
Versions:
ubuntu 10.04
eclipse / SpringToolSuite 3.4.0
grails 2.3.6
groovy 2.1.9 (for both project and workspace)
Update 13/03/2014
I followed Joe's suggestions (below) and found that the problem is indeed in the ImcaReferral.list() method.
In the grails console simply running:
package com.ubergen
ImcaReferral.withTransaction { status ->
ImcaReferral.list()
}
Returns
java.lang.ArrayIndexOutOfBoundsException: 0
at org.hibernate.criterion.Order.toSqlString(Order.java:73)
at org.hibernate.loader.criteria.CriteriaQueryTranslator.getOrderBy(CriteriaQueryTranslator.ja a:394)
[snip]
at com.ubergen.ImcaReferral.list(ImcaReferral.groovy)
Looking at the domain's sort order information BINGO! its incorrectly defined, there are two competing definitions of how to sort the domain.
I Comment out the erroneous sort order information:
package com.ubergen
class ImcaReferral {
...
static hasMany = [challenges:Challenge]
static mapping = {
...
sort dateReceived:'asc'
// sort challenges:'challengeRoute' // *** ERROR ***
}
}
and (after restarting the console) the call to list works fine and returns an empty array.
Correcting the sort order of the child records:
package com.ubergen
class ImcaReferral {
...
static hasMany = [challenges:Challenge]
static mapping = {
...
sort dateReceived:'asc'
challenges sort: 'challengeRoute', order: 'asc' // *** CORRECT ***
}
}
Fixes the problem. The scaffolding now works.
Conclusions
Trust the full stacktrace even if its rather verbose. It shows the classes and methods to look at.
Learn to use the console.
grails -reloading console
Read your more code carefully!
You could try to generate the Static Scaffolding and see if you get a different result. You could also try running the list in a integration test to see what happens.