test@debian:~/TestApp$rails s => Booting Puma => Rails 6.0.2.1 application starting in development => Run `rails server --help` for more startup options Puma starting in single mode... * Version 4.3.1 (ruby 2.6.5-p114), codename: Mysterious Traveller * Min threads: 5, max threads: 5 * Environment: development * Listening on tcp://127.0.0.1:3000 * Listening on tcp://[::1]:3000 Use Ctrl-C to stop
test@debian:~/TestApp$yarn add jquery yarn add v1.21.1 [1/4] Resolving packages... [2/4] Fetching packages... info [email protected]: The platform "linux" is incompatible with this module. info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation. [3/4] Linking dependencies... warning " > [email protected]" has unmet peer dependency "webpack@^4.0.0 || ^5.0.0". warning "webpack-dev-server > [email protected]" has unmet peer dependency "webpack@^4.0.0". [4/4] Building fresh packages...
success Saved lockfile. success Saved 1 new dependency. info Direct dependencies └─ [email protected] info All dependencies └─ [email protected] Done in 9.98s. test@debian:~/TestApp$yarn add bootstrap yarn add v1.21.1 [1/4] Resolving packages... [2/4] Fetching packages... info [email protected]: The platform "linux" is incompatible with this module. info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation. [3/4] Linking dependencies... warning " > [email protected]" has unmet peer dependency "webpack@^4.0.0 || ^5.0.0". warning "webpack-dev-server > [email protected]" has unmet peer dependency "webpack@^4.0.0". warning " > [email protected]" has unmet peer dependency "popper.js@^1.16.0". [4/4] Building fresh packages...
success Saved lockfile. success Saved 1 new dependency. info Direct dependencies └─ [email protected] info All dependencies └─ [email protected] Done in 13.33s.
test@debian:~/TestApp$yarn add popper.js yarn add v1.21.1 [1/4] Resolving packages... warning [email protected]: You can find the new Popper v2 at @popperjs/core, this package is dedicated to the legacy v1 [2/4] Fetching packages... info [email protected]: The platform "linux" is incompatible with this module. info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation. [3/4] Linking dependencies... warning " > [email protected]" has unmet peer dependency "webpack@^4.0.0 || ^5.0.0". warning "webpack-dev-server > [email protected]" has unmet peer dependency "webpack@^4.0.0". [4/4] Building fresh packages... success Saved lockfile. success Saved 1 new dependency. info Direct dependencies └─ [email protected] info All dependencies └─ [email protected] Done in 11.78s.
/* * File: app/assets/stylesheets/application.css * This is a manifest file that'll be compiled into application.css, which will include all the files * listed below. * * Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's * vendor/assets/stylesheets directory can be referenced here using a relative path. * * You're free to add application-wide styles to this file and they'll appear at the bottom of the * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS * files in this directory. Styles in this file should be added after the last require_* statement. * It is generally better to create a new file per style scope. * *= require bootstrap/dist/css/bootstrap *= require_tree . *= require_self */
// This file is automatically compiled by Webpack, along with any other files // present in this directory. You're encouraged to place your actual application logic in // a relevant structure within app/javascript and only use these pack files to reference // that code so it'll be compiled.
// Uncomment to copy all static images under ../images to the output folder and reference // them with the image_pack_tag helper in views (e.g <%= image_pack_tag 'rails.png' %>) // or the `imagePath` JavaScript helper below. // // const images = require.context('../images', true) // const imagePath = (name) => images(name, true)
// This file is automatically compiled by Webpack, along with any other files // present in this directory. You're encouraged to place your actual application logic in // a relevant structure within app/javascript and only use these pack files to reference // that code so it'll be compiled.
// Uncomment to copy all static images under ../images to the output folder and reference // them with the image_pack_tag helper in views (e.g <%= image_pack_tag 'rails.png' %>) // or the `imagePath` JavaScript helper below. // // const images = require.context('../images', true) // const imagePath = (name) => images(name, true)
[root@localhost ~ ]# gem install sassc Building native extensions. This could take a while... ERROR: Error installing sassc: ERROR: Failed to build gem native extension.
current directory: /usr/local/rvm/gems/ruby-2.6.2/gems/sassc-2.0.1/ext /usr/local/rvm/rubies/ruby-2.6.2/bin/ruby -rrubygems /usr/local/rvm/rubies/ruby-2.6.2/lib/ruby/gems/2.6.0/gems/rake-12.3.2/exe/rake RUBYARCHDIR\=/usr/local/rvm/gems/ruby-2.6.2/extensions/x86_64-linux/2.6.0/sassc-2.0.1 RUBYLIBDIR\=/usr/local/rvm/gems/ruby-2.6.2/extensions/x86_64-linux/2.6.0/sassc-2.0.1 cd libsass make lib/libsass.so mkdir lib cc -Wall -O2 -I /usr/local/rvm/gems/ruby-2.6.2/gems/sassc-2.0.1/ext/libsass/include -fPIC -fPIC -c -o src/cencode.o src/cencode.c src/cencode.c: In function ‘base64_encode_block’: src/cencode.c:50: warning: empty declaration src/cencode.c:64: warning: empty declaration g++ -Wall -O2 -std=c++0x -I /usr/local/rvm/gems/ruby-2.6.2/gems/sassc-2.0.1/ext/libsass/include -fPIC -fPIC -c -o src/ast.o src/ast.cpp In file included from src/ast.cpp:2: src/ast.hpp: In member function ‘virtual size_t Sass::Vectorized<T>::hash()’: src/ast.hpp:336: error: expected initializer before ‘:’ token src/ast.hpp:339: error: expected primary-expression before ‘}’ token src/ast.hpp:339: error: expected ‘;’ before ‘}’ token src/ast.hpp:339: error: expected primary-expression before ‘}’ token src/ast.hpp:339: error: expected ‘)’ before ‘}’ token src/ast.hpp:339: error: expected primary-expression before ‘}’ token src/ast.hpp:339: error: expected ‘;’ before ‘}’ token src/ast.hpp: In constructor ‘Sass::Hashed::Hashed(size_t)’: src/ast.hpp:373: error: ‘class Sass::ExpressionMap’ has no member named ‘reserve’ src/ast.hpp: In member function ‘Sass::Hashed& Sass::Hashed::operator+=(Sass::Hashed*)’: src/ast.hpp:402: error: expected initializer before ‘:’ token src/ast.hpp:406: error: could not convert ‘Sass::Hashed::reset_duplicate_key()’ to ‘bool’ src/ast.hpp:407: error: expected primary-expression before ‘return’ src/ast.hpp:407: error: expected ‘)’ before ‘return’ In file included from src/ast.cpp:2: src/ast.hpp: In member function ‘virtual size_t Sass::Map::hash()’: src/ast.hpp:1153: error: expected initializer before ‘:’ token src/ast.hpp:1157: error: expected primary-expression before ‘}’ token src/ast.hpp:1157: error: expected ‘;’ before ‘}’ token src/ast.hpp:1157: error: expected primary-expression before ‘}’ token src/ast.hpp:1157: error: expected ‘)’ before ‘}’ token src/ast.hpp:1157: error: expected primary-expression before ‘}’ token src/ast.hpp:1157: error: expected ‘;’ before ‘}’ token src/ast.hpp: In member function ‘virtual size_t Sass::Function_Call::hash()’: src/ast.hpp:1522: error: expected initializer before ‘:’ token src/ast.hpp:1524: error: expected primary-expression before ‘}’ token src/ast.hpp:1524: error: expected ‘;’ before ‘}’ token src/ast.hpp:1524: error: expected primary-expression before ‘}’ token src/ast.hpp:1524: error: expected ‘)’ before ‘}’ token src/ast.hpp:1524: error: expected primary-expression before ‘}’ token src/ast.hpp:1524: error: expected ‘;’ before ‘}’ token src/ast.hpp: In member function ‘virtual size_t Sass::Number::hash()’: src/ast.hpp:1614: error: expected initializer before ‘:’ token src/ast.hpp:1616: error: expected primary-expression before ‘for’ src/ast.hpp:1616: error: expected ‘;’ before ‘for’ src/ast.hpp:1616: error: expected primary-expression before ‘for’ src/ast.hpp:1616: error: expected ‘)’ before ‘for’ src/ast.hpp:1616: error: expected initializer before ‘:’ token src/ast.hpp:1618: error: expected primary-expression before ‘}’ token src/ast.hpp:1618: error: expected ‘;’ before ‘}’ token src/ast.hpp:1618: error: expected primary-expression before ‘}’ token src/ast.hpp:1618: error: expected ‘)’ before ‘}’ token src/ast.hpp:1618: error: expected primary-expression before ‘}’ token src/ast.hpp:1618: error: expected ‘;’ before ‘}’ token src/ast.hpp: In member function ‘bool Sass::String_Schema::has_interpolants()’: src/ast.hpp:1791: error: expected initializer before ‘:’ token src/ast.hpp:1794: error: expected primary-expression before ‘return’ src/ast.hpp:1794: error: expected ‘;’ before ‘return’ src/ast.hpp:1794: error: expected primary-expression before ‘return’ src/ast.hpp:1794: error: expected ‘)’ before ‘return’ src/ast.hpp: In member function ‘virtual size_t Sass::String_Schema::hash()’: src/ast.hpp:1801: error: expected initializer before ‘:’ token src/ast.hpp:1803: error: expected primary-expression before ‘}’ token src/ast.hpp:1803: error: expected ‘;’ before ‘}’ token src/ast.hpp:1803: error: expected primary-expression before ‘}’ token src/ast.hpp:1803: error: expected ‘)’ before ‘}’ token src/ast.hpp:1803: error: expected primary-expression before ‘}’ token src/ast.hpp:1803: error: expected ‘;’ before ‘}’ token src/ast.hpp: In member function ‘virtual size_t Sass::Compound_Selector::hash()’: src/ast.hpp:2750: error: ‘template<class T> class Sass::Vectorized’ used without template parameters src/ast.hpp: In member function ‘virtual size_t Sass::Selector_List::hash()’: src/ast.hpp:2997: error: ‘template<class T> class Sass::Vectorized’ used without template parameters src/ast.hpp: In member function ‘virtual void Sass::Selector_List::set_media_block(Sass::Media_Block*)’: src/ast.hpp:3014: error: expected initializer before ‘:’ token src/ast.hpp:3017: error: expected primary-expression before ‘}’ token src/ast.hpp:3017: error: expected ‘;’ before ‘}’ token src/ast.hpp:3017: error: expected primary-expression before ‘}’ token src/ast.hpp:3017: error: expected ‘)’ before ‘}’ token src/ast.hpp:3017: error: expected primary-expression before ‘}’ token src/ast.hpp:3017: error: expected ‘;’ before ‘}’ token src/ast.hpp: In member function ‘virtual bool Sass::Selector_List::has_placeholder()’: src/ast.hpp:3019: error: expected initializer before ‘:’ token src/ast.hpp:3022: error: expected primary-expression before ‘return’ src/ast.hpp:3022: error: expected ‘;’ before ‘return’ src/ast.hpp:3022: error: expected primary-expression before ‘return’ src/ast.hpp:3022: error: expected ‘)’ before ‘return’ src/ast.cpp: In member function ‘virtual bool Sass::Selector_List::find(bool (*)(Sass::AST_Node_Obj))’: src/ast.cpp:35: error: expected initializer before ‘:’ token src/ast.cpp:39: error: expected primary-expression before ‘return’ src/ast.cpp:39: error: expected ‘;’ before ‘return’ src/ast.cpp:39: error: expected primary-expression before ‘return’ src/ast.cpp:39: error: expected ‘)’ before ‘return’ src/ast.cpp: In member function ‘virtual bool Sass::Compound_Selector::find(bool (*)(Sass::AST_Node_Obj))’: src/ast.cpp:45: error: expected initializer before ‘:’ token src/ast.cpp:49: error: expected primary-expression before ‘return’ src/ast.cpp:49: error: expected ‘;’ before ‘return’ src/ast.cpp:49: error: expected primary-expression before ‘return’ src/ast.cpp:49: error: expected ‘)’ before ‘return’ src/ast.cpp: In member function ‘virtual void Sass::Arguments::set_delayed(bool)’: src/ast.cpp:98: error: expected initializer before ‘:’ token src/ast.cpp:102: error: expected primary-expression before ‘}’ token src/ast.cpp:102: error: expected ‘)’ before ‘}’ token src/ast.cpp:102: error: expected primary-expression before ‘}’ token src/ast.cpp:102: error: expected ‘;’ before ‘}’ token src/ast.cpp: In member function ‘virtual bool Sass::Compound_Selector::has_parent_ref() const’: src/ast.cpp:171: error: expected initializer before ‘:’ token src/ast.cpp:174: error: expected primary-expression before ‘return’ src/ast.cpp:174: error: expected ‘;’ before ‘return’ src/ast.cpp:174: error: expected primary-expression before ‘return’ src/ast.cpp:174: error: expected ‘)’ before ‘return’ src/ast.cpp: In member function ‘virtual bool Sass::Compound_Selector::has_real_parent_ref() const’: src/ast.cpp:179: error: expected initializer before ‘:’ token src/ast.cpp:182: error: expected primary-expression before ‘return’ src/ast.cpp:182: error: expected ‘;’ before ‘return’ src/ast.cpp:182: error: expected primary-expression before ‘return’ src/ast.cpp:182: error: expected ‘)’ before ‘return’ src/ast.cpp: In member function ‘virtual bool Sass::Compound_Selector::is_superselector_of(Sass::Selector_List_Obj, std::string)’: src/ast.cpp:846: error: expected initializer before ‘:’ token src/ast.cpp:849: error: expected primary-expression before ‘return’ src/ast.cpp:849: error: expected ‘;’ before ‘return’ src/ast.cpp:849: error: expected primary-expression before ‘return’ src/ast.cpp:849: error: expected ‘)’ before ‘return’ src/ast.cpp: In member function ‘Sass::Selector_List* Sass::Complex_Selector::resolve_parent_refs(std::vector<Sass::SharedImpl<Sass::Selector_List>, std::allocator<Sass::SharedImpl<Sass::Selector_List> > >&, Sass::Backtraces&, bool)’: src/ast.cpp:1408: error: expected initializer before ‘:’ token src/ast.cpp:2226: error: expected primary-expression at end of input src/ast.cpp:2226: error: expected ‘;’ at end of input src/ast.cpp:2226: error: expected primary-expression at end of input src/ast.cpp:2226: error: expected ‘)’ at end of input src/ast.cpp:2226: error: expected statement at end of input src/ast.cpp:2226: error: expected ‘}’ at end of input src/ast.cpp:2226: error: expected ‘}’ at end of input src/ast.cpp: At global scope: src/ast.cpp:2226: error: expected ‘}’ at end of input src/units.hpp:11: warning: ‘Sass::PI’ defined but not used make: *** [src/ast.o] Error 1 rake aborted! Command failed with status (2): [make lib/libsass.so...] /usr/local/rvm/gems/ruby-2.6.2/gems/sassc-2.0.1/lib/tasks/libsass.rb:31:in `block (2 levels) in <top (required)>' /usr/local/rvm/gems/ruby-2.6.2/gems/sassc-2.0.1/lib/tasks/libsass.rb:13:in `block (3 levels) in <top (required)>' /usr/local/rvm/gems/ruby-2.6.2/gems/sassc-2.0.1/lib/tasks/libsass.rb:12:in `block (2 levels) in <top (required)>' Tasks: TOP => lib/libsass.so (See full trace by running task with --trace)
rake failed, exit code 1
Gem files will remain installed in /usr/local/rvm/gems/ruby-2.6.2/gems/sassc-2.0.1 for inspection. Results logged to /usr/local/rvm/gems/ruby-2.6.2/extensions/x86_64-linux/2.6.0/sassc-2.0.1/gem_make.out
经排查,是因为GCC的版本过低导致的。
按照这个步骤,检查下GCC版本,如果是同样的版本和报错,那么可以参考以下的解决方法:
1 2
[root@localhost ~]# gcc --version | head -n1 gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-23)
#config/routes.rb Rails.application.routes.draw do post 'images/upload' => 'upload#upload' resources :articles root to:'articles#index' # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html end
Puma caught this error: Error loading the 'sqlite3' Active Record adapter. Missing a gem it depends on? can't activate sqlite3 (~> 1.3.6), already activated sqlite3-1.4.0. Make sure all dependencies are added to Gemfile. (LoadError)
页面报错如下:
1 2 3
ActiveRecord::ConnectionNotEstablished No connection pool with 'primary' found.
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '~> 5.2.2' # Use sqlite3 as the database for Active Record gem 'sqlite3', '< 1.4.0'# <<修改这里,将sqlite3版本设定为小于1.4.0 # Use Puma as the app server gem 'puma', '~> 3.11' # Use SCSS for stylesheets gem 'sass-rails', '~> 5.0' # Use Uglifier as compressor for JavaScript assets gem 'uglifier', '>= 1.3.0' # See https://github.com/rails/execjs#readme for more supported runtimes # gem 'mini_racer', platforms: :ruby
# Use CoffeeScript for .coffee assets and views gem 'coffee-rails', '~> 4.2' # Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks gem 'turbolinks', '~> 5' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder gem 'jbuilder', '~> 2.5' # Use Redis adapter to run Action Cable in production # gem 'redis', '~> 4.0' # Use ActiveModel has_secure_password # gem 'bcrypt', '~> 3.1.7'
# Use ActiveStorage variant # gem 'mini_magick', '~> 4.8'
# Use Capistrano for deployment # gem 'capistrano-rails', group: :development
# Reduces boot times through caching; required in config/boot.rb gem 'bootsnap', '>= 1.1.0', require:false
group :development, :testdo # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] end
group :developmentdo # Access an interactive console on exception pages or by calling 'console' anywhere in the code. gem 'web-console', '>= 3.3.0' gem 'listen', '>= 3.0.5', '< 3.2' # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring gem 'spring' gem 'spring-watcher-listen', '~> 2.0.0' end
group :testdo # Adds support for Capybara system testing and selenium driver gem 'capybara', '>= 2.15' gem 'selenium-webdriver' # Easy installation and use of chromedriver to run system tests with Chrome gem 'chromedriver-helper' end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
require'mysql' begin db = Mysql.init db.options(Mysql::SET_CHARSET_NAME, 'utf8') db = Mysql.real_connect("127.0.0.1", "root", "123456", "test", 3306) db.query("SET NAMES utf8") db.query("drop table if exists tb_test") db.query("create table tb_test (id int, text LONGTEXT) ENGINE=MyISAM DEFAULT CHARSET=utf8") db.query("insert into tb_test (id, text) values ( 1,'first line'),(2,'second line')") printf "%d rows were inserted\n",db.affected_rows rslt = db.query("select text from tb_test") while row = rslt.fetch_row do puts row[0] end rescueMysql::Error => e puts "Error code: #{e.errno}" puts "Error message: #{e.error}" puts "Error SQLSTATE: #{e.sqlstate}"if e.respond_to?("sqlstate") ensure db.close if db end
defwriteToFile(file,content) fp = File.new(file,"a+") if fp fp.syswrite(content) else puts "..." end end
defconnect(host) redis = Redis.new(:host => host,:port => 6379) redis.info.keys.each do |key| puts "#{key}:\t"+redis.info["#{key}"] end end
connect("1.1.1.1")
sqlite3
1 2 3 4 5 6 7 8 9 10 11 12
require'sqlite3'
db = SQLite3::Database.new('test.db')
db.execute("create table test( ID integet not null, Username varchar(20) null, Password varchar(64) null)") db.execute("insert into test(ID.Username,Password) values('0','admin','admin')") db.execute("select * from test") db.execute("update test set password='12345' where id=0")
3.Ruby socket
服务端:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
require'socket'
server = TCPServer.open('0.0.0.0', 8080) loop do Thread.start(server.accept) do |client| begin whiletrue puts "#{client.to_i} online" data = client.read() throw"empty"if data.empty? #puts data.length puts data end rescueException => e puts "#{client.to_i} offline" end end end
客户端:
1 2 3 4 5 6 7 8 9
require'socket'
hostname = '127.0.0.1' port = 8080 buf = 'test' s = TCPSocket.open(hostname, port) s.write buf sleep(1) s.close